Pyd thread

Maxim Fomin maxim at maxim-fomin.ru
Thu Nov 15 00:26:18 PST 2012


On Thursday, 15 November 2012 at 02:51:08 UTC, Ellery Newcomer 
wrote:
> Just tried building a shared library on linux with dmd (and 
> calling it from C).
>
> It works! Holy crap, it even runs my static constructors and 
> unittests! I only had to screw with the linking process a 
> little bit!
>
> It doesn't work for x64, though. Gives me
>
> /usr/bin/ld: /usr/lib64/dmd/libphobos2.a(object__c_58c.o): 
> relocation R_X86_64_32 against `_D10TypeInfo_m6__initZ' can not 
> be used when making a shared object; recompile with -fPIC
> /usr/lib64/dmd/libphobos2.a: could not read symbols: Bad value
> collect2: ld returned 1 exit status
> --- errorlevel 1
>
> Though why it doesn't do this for x32 is beyond me. Those 
> object files don't appear to be -fPIC either.

You can dynamically link to D shared libraries on linux 
(http://forum.dlang.org/thread/k3vfm9$1tq$1@digitalmars.com?page=2). 
The message you receive actually means that you cannot make a 
shared library from current version of Phobos and Druntime due to 
how they are compiled. However I saw several people working on 
making druntime shared. The solution is not to put druntime in 
.so file.

I tried to investigate which features do not work with dynamic 
linking (not loading) and found certainly one - it is related to 
not invoking scope(XXX) statements at some circumstances.




More information about the Digitalmars-d mailing list