Dynamically calling external libraries.

Marc Schütz" <schuetzm at gmx.net> Marc Schütz" <schuetzm at gmx.net>
Fri Feb 28 09:05:44 PST 2014


On Friday, 28 February 2014 at 16:44:02 UTC, Setra wrote:
> Marc would you be willing to post your compile script? Or did 
> you just use what the wiki said to?

I used exactly what I quoted in my post:

dmd main1.d -L-ldl
dmd -c dll.d -fPIC
dmd -oflibdll.so dll.o -shared -defaultlib=
LD_LIBRARY_PATH=. ./main1

But what you just wrote works correctly, too.

Are you sure you're actually using the correct object files? I.e. 
try deleting all output files first. Sometimes it's really 
trivialities like this :-)

Or it's an architectural problem? I'm on x86_64, maybe you're 
compiling 32bit code (although of course that should work, but 
you can never know)?

Which version of DMD are you using?

Otherwise you could try disassembling things or single-step 
through the call with a debugger.

But maybe someone else knows something better?


More information about the Digitalmars-d-learn mailing list