www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Linux Shared Library Fun

reply jeff <jhair acm.org> writes:
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.
Apr 11 2009
parent jeff <jhair acm.org> writes:
jeff wrote:
 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.
And also I apologize profusely in advance if this isn't the proper newsgroup to put this in...
Apr 11 2009