Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 28, 2016 Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
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. |
January 28, 2016 Re: Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | 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).
|
January 28, 2016 Re: Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to FreeSlave | 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 |
January 28, 2016 Re: Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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:
>> 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
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.
|
January 29, 2016 Re: Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | 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: >> 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 > > 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. 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.html |
January 30, 2016 Re: Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | 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: >> 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: >>>> 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 >> >> 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. > > 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.html 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 ======================================================================= |
January 30, 2016 Re: Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | 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 directory > The 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/ |
January 30, 2016 Re: Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | 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: > >> 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 directory >> > > The 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/ 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 directory |
January 30, 2016 Re: Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | 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:
>> [...]
>
> 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.
>
> [...]
Acctually I made multiple mistakes. 0x000000000000000f (RPATH) Library rpath:[--export-dynamic] should be [lib]
Ill fix that and test again.
|
January 30, 2016 Re: Can D interface with Free Pascal? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Taylor Hillegeist | 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:
>> On Saturday, 30 January 2016 at 04:11:07 UTC, Mike Parker 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.
>>
>> [...]
>
> Acctually I made multiple mistakes. 0x000000000000000f (RPATH) Library rpath:[--export-dynamic] should be [lib]
>
> Ill fix that and test again.
dmd Gethello.d -Llibhello.so -L"-rpath=./" made it use the CWD able to load libraries! cool!
|
Copyright © 1999-2021 by the D Language Foundation