Linux Shared Library Fun
jeff
jhair at acm.org
Sat Apr 11 16:10:02 PDT 2009
So, I've been messing around with creating shared libraries in D and
then dynamically loading them into another D program and calling the
functions. Thus far this is very simple: just using a function that
prints "hello" in the library and then the main program loads it.
This whole thing works perfectly if the library is created in C and
compiled into a .so with gcc. Fun problems arise when I try to compile
the library in D with gdc (since dmd does not support creation of
libraries under Linux... which makes me sad). The compilation and
creation of the library itself is fine... However, when I try to load
the library in the main program it comes up with this fun error:
./testlib.so: undefined symbol: __data_start
I'm using dlopen, dlsym, etc to pull stuff from the library. I also
tried std.loader but since it's basically a front-end to dlopen the same
error occurs.
nm indeed shows that __data_start is undefined in the compiled D
library. I've tried lazy binding and that does not solve the problem either.
Any ideas would be appreciated.
More information about the Digitalmars-d
mailing list