digitalmars.D.learn - Can D interface with Free Pascal?
- Taylor Hillegeist (4/4) Jan 27 2016 Just curious... I had a thought that perhaps since Objective C
- FreeSlave (4/8) Jan 28 2016 Not directly. You can declare cdecl function on Free Pascal side
- bearophile (6/8) Jan 28 2016 What about extern(Pascal)?
- Taylor Hillegeist (4/12) Jan 28 2016 Cool!, I did find this little gem. but still havent gotten a
- Mike Parker (8/23) Jan 28 2016 AFAIK, FreePascal does not use the pascal calling convention by
- Taylor Hillegeist (27/51) Jan 29 2016 Working through a simple example. I tried the cdecl option but
- Mike Parker (6/16) Jan 29 2016 The binary's directory is not on the system search path by
- Taylor Hillegeist (45/61) Jan 29 2016 Now I'm wishing that was the problem. Interestingly enough when i
- Taylor Hillegeist (5/11) Jan 29 2016 Acctually I made multiple mistakes. 0x000000000000000f (RPATH)
- Taylor Hillegeist (4/18) Jan 29 2016 dmd Gethello.d -Llibhello.so -L"-rpath=./" made it use the CWD
- Basile B. (18/22) Feb 08 2016 As said in the other posts you can link dlls or even object files
Just curious... I had a thought that perhaps since Objective C was a replacement for Pascal on the mac. that they might have the same interface. but I'm not savvy enough with fpc to figure out how to try it.
Jan 27 2016
On Thursday, 28 January 2016 at 04:26:26 UTC, Taylor Hillegeist wrote:Just curious... I had a thought that perhaps since Objective C was a replacement for Pascal on the mac. that they might have the same interface. but I'm not savvy enough with fpc to figure out how to try it.Not directly. You can declare cdecl function on Free Pascal side and call it as extern(C).
Jan 28 2016
FreeSlave: On Thursday, 28 January 2016 at 08:15:38 UTC, FreeSlave wrote:Not directly. You can declare cdecl function on Free Pascal side and call it as extern(C).What about extern(Pascal)? https://dlang.org/spec/attribute.html#linkage Bye, bearophile
Jan 28 2016
On Thursday, 28 January 2016 at 19:33:22 UTC, bearophile wrote:FreeSlave: On Thursday, 28 January 2016 at 08:15:38 UTC, FreeSlave wrote:Cool!, I did find this little gem. but still havent gotten a hello world to work. I need to figure out which libraries i need to include for fpc dependencies.Not directly. You can declare cdecl function on Free Pascal side and call it as extern(C).What about extern(Pascal)? https://dlang.org/spec/attribute.html#linkage Bye, bearophile
Jan 28 2016
On Thursday, 28 January 2016 at 19:49:22 UTC, Taylor Hillegeist wrote:On Thursday, 28 January 2016 at 19:33:22 UTC, bearophile wrote:AFAIK, FreePascal does not use the pascal calling convention by default. If this page [1] is correct, the default convention is 'register' and can be changed to something else (like pascal or cdecl) with a command-line switch [2]. [1] http://www.freepascal.org/docs-html/prog/progse22.html [2] http://www.freepascal.org/docs-html/prog/progsu87.htmlFreeSlave: On Thursday, 28 January 2016 at 08:15:38 UTC, FreeSlave wrote:Cool!, I did find this little gem. but still havent gotten a hello world to work. I need to figure out which libraries i need to include for fpc dependencies.Not directly. You can declare cdecl function on Free Pascal side and call it as extern(C).What about extern(Pascal)? https://dlang.org/spec/attribute.html#linkage Bye, bearophile
Jan 28 2016
On Friday, 29 January 2016 at 01:47:11 UTC, Mike Parker wrote:On Thursday, 28 January 2016 at 19:49:22 UTC, Taylor Hillegeist wrote:Working through a simple example. I tried the cdecl option but for some reason i can compile but when i run my Gethello it cant find the shared library in the same folder? ==================================================================== taylor taylor-NE510:~/Projects/PASCAL$ ls Gethello Gethello.d hello.pas libhello.so taylor taylor-NE510:~/Projects/PASCAL$ cat Gethello.d extern(C) void SubStr(); void main(){ SubStr(); } taylor taylor-NE510:~/Projects/PASCAL$ cat hello.pas library subs; procedure SubStr(); cdecl; begin write('hello World'); end; exports SubStr; end. taylor taylor-NE510:~/Projects/PASCAL$ nm libhello.so 0000000000003ac0 T SubStr taylor taylor-NE510:~/Projects/PASCAL$ ./Gethello ./Gethello: error while loading shared libraries: libhello.so: cannot open shared object file: No such file or directory =======================================================================On Thursday, 28 January 2016 at 19:33:22 UTC, bearophile wrote:AFAIK, FreePascal does not use the pascal calling convention by default. If this page [1] is correct, the default convention is 'register' and can be changed to something else (like pascal or cdecl) with a command-line switch [2]. [1] http://www.freepascal.org/docs-html/prog/progse22.html [2] http://www.freepascal.org/docs-html/prog/progsu87.htmlFreeSlave: On Thursday, 28 January 2016 at 08:15:38 UTC, FreeSlave wrote:Cool!, I did find this little gem. but still havent gotten a hello world to work. I need to figure out which libraries i need to include for fpc dependencies.Not directly. You can declare cdecl function on Free Pascal side and call it as extern(C).What about extern(Pascal)? https://dlang.org/spec/attribute.html#linkage Bye, bearophile
Jan 29 2016
On Saturday, 30 January 2016 at 03:43:59 UTC, Taylor Hillegeist wrote:Working through a simple example. I tried the cdecl option but for some reason i can compile but when i run my Gethello it cant find the shared library in the same folder? taylor taylor-NE510:~/Projects/PASCAL$ nm libhello.so 0000000000003ac0 T SubStr taylor taylor-NE510:~/Projects/PASCAL$ ./Gethello ./Gethello: error while loading shared libraries: libhello.so: cannot open shared object file: No such file or directoryThe binary's directory is not on the system search path by default on Linux. This page [1] shows three possible solutions. [1] http://www.aimlesslygoingforward.com/2014/01/19/bundling-shared-libraries-on-linux/
Jan 29 2016
On Saturday, 30 January 2016 at 04:11:07 UTC, Mike Parker wrote:On Saturday, 30 January 2016 at 03:43:59 UTC, Taylor Hillegeist wrote:Now I'm wishing that was the problem. Interestingly enough when i link to a C shared library it works... but also it isn't show in the needed shared library sections like below. taylor taylor-NE510:~/Projects/PASCAL$ readelf -d Gethello Dynamic section at offset 0x26dd8 contains 29 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libhello.so] 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0] 0x0000000000000001 (NEEDED) Shared library: [librt.so.1] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2] 0x000000000000000f (RPATH) Library rpath: [--export-dynamic] 0x000000000000000c (INIT) 0x4017f8 0x000000000000000d (FINI) 0x424444 0x0000000000000019 (INIT_ARRAY) 0x626db0 0x000000000000001b (INIT_ARRAYSZ) 16 (bytes) 0x000000000000001a (FINI_ARRAY) 0x626dc0 0x000000000000001c (FINI_ARRAYSZ) 16 (bytes) 0x000000006ffffef5 (GNU_HASH) 0x4002d0 0x0000000000000005 (STRTAB) 0x400aa8 0x0000000000000006 (SYMTAB) 0x4002f8 0x000000000000000a (STRSZ) 1202 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000015 (DEBUG) 0x0 0x0000000000000003 (PLTGOT) 0x627000 0x0000000000000002 (PLTRELSZ) 1824 (bytes) 0x0000000000000014 (PLTREL) RELA 0x0000000000000017 (JMPREL) 0x4010d8 0x0000000000000007 (RELA) 0x401090 0x0000000000000008 (RELASZ) 72 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) 0x000000006ffffffe (VERNEED) 0x401000 0x000000006fffffff (VERNEEDNUM) 4 0x000000006ffffff0 (VERSYM) 0x400f5a 0x0000000000000000 (NULL) 0x0 taylor taylor-NE510:~/Projects/PASCAL$ ./Gethello ./Gethello: error while loading shared libraries: libhello.so: cannot open shared object file: No such file or directoryWorking through a simple example. I tried the cdecl option but for some reason i can compile but when i run my Gethello it cant find the shared library in the same folder? taylor taylor-NE510:~/Projects/PASCAL$ nm libhello.so 0000000000003ac0 T SubStr taylor taylor-NE510:~/Projects/PASCAL$ ./Gethello ./Gethello: error while loading shared libraries: libhello.so: cannot open shared object file: No such file or directoryThe binary's directory is not on the system search path by default on Linux. This page [1] shows three possible solutions. [1] http://www.aimlesslygoingforward.com/2014/01/19/bundling-shared-libraries-on-linux/
Jan 29 2016
On Saturday, 30 January 2016 at 04:35:29 UTC, Taylor Hillegeist wrote:On Saturday, 30 January 2016 at 04:11:07 UTC, Mike Parker wrote:Acctually I made multiple mistakes. 0x000000000000000f (RPATH) Library rpath:[--export-dynamic] should be [lib] Ill fix that and test again.[...]Now I'm wishing that was the problem. Interestingly enough when i link to a C shared library it works... but also it isn't show in the needed shared library sections like below. [...]
Jan 29 2016
On Saturday, 30 January 2016 at 04:49:39 UTC, Taylor Hillegeist wrote:On Saturday, 30 January 2016 at 04:35:29 UTC, Taylor Hillegeist wrote:dmd Gethello.d -Llibhello.so -L"-rpath=./" made it use the CWD able to load libraries! cool!On Saturday, 30 January 2016 at 04:11:07 UTC, Mike Parker wrote:Acctually I made multiple mistakes. 0x000000000000000f (RPATH) Library rpath:[--export-dynamic] should be [lib] Ill fix that and test again.[...]Now I'm wishing that was the problem. Interestingly enough when i link to a C shared library it works... but also it isn't show in the needed shared library sections like below. [...]
Jan 29 2016
On Thursday, 28 January 2016 at 04:26:26 UTC, Taylor Hillegeist wrote:Just curious... I had a thought that perhaps since Objective C was a replacement for Pascal on the mac. that they might have the same interface. but I'm not savvy enough with fpc to figure out how to try it.As said in the other posts you can link dlls or even object files produced by a D compiler. There is the D runtime to initialize and finalize, a particular attention must be put on te calling conventions, also some stuff like strings must be passed using toStringz() or received with fromStringz() (and Pchar() in pascal)... One thing that's interesting is to develop let's say the GUI with Lazarus and use a core made in D. When you'll debug your application in Lazarus, and if an exception is raised within the object or the dll made in D, the integrated debugger will break and display the D source directly in Lazarus. The first time it happend to me, I was **totally mesmerized**... (I even made a post here: https://forum.dlang.org/thread/aeiwsnmsrchgmkbllqid forum.dlang.org "//debugger breaks here": it was the Lazarus debugger who displayed a D source). But actually it's totally logical, it's just the DWARF debug info that indicates the source name...
Feb 08 2016