www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Compile a .so

reply Sebastian <sebastian.faltoni gmail.com> writes:
hi,
is possibile to compile .so for linux and for mac, with D? if true how i can do
that?
thanks
Apr 07 2007
next sibling parent Clay Smith <clayasaurus gmail.com> writes:
Sebastian wrote:
 hi,
 is possibile to compile .so for linux and for mac, with D? if true how i can
do that?
 thanks
Use GDC maybe? http://sourceforge.net/project/showfiles.php?group_id=154306 ~ Clay
Apr 08 2007
prev sibling parent reply nobody nowhere.nonet writes:
Sebastian <sebastian.faltoni gmail.com> spewed this unto the Network: 
 hi, is possibile to compile .so for linux and for mac, with D? if
 true how i can do that?  thanks
This isn't handled by a compiler, but the linker, ld. First, you get the D compiler to generate an .o file. The "-c" option accomplishes this in both the DMD and GDC compilers: gdc -c foo.d Then, the "ld" command line is as follows: ld -shared foo.o -o foo.so -- All your .signature are belong to us. Take off every 'sig' for great justice.
Apr 28 2007
parent Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
nobody nowhere.nonet wrote:
 Sebastian <sebastian.faltoni gmail.com> spewed this unto the Network: 
 hi, is possibile to compile .so for linux and for mac, with D? if
 true how i can do that?  thanks
This isn't handled by a compiler, but the linker, ld. First,
Are you sure? Shouldn't the compiler generate position-independent code? (That's what I seem to remember and will assume for the rest of the code. It that's not true, please ignore the rest of this post :) )
 you get the D compiler to generate an .o file. The "-c" option
 accomplishes this in both the DMD and GDC compilers:
 

 	gdc -c foo.d
This generates relocatable code, not position-independent code. For that, you need to specify -fpic or -fPIC (for GDC, DMD can't do this IIRC).
 Then, the "ld" command line is as follows:
 
 	ld -shared foo.o -o foo.so
This would be correct if foo.o contained position-independent code.
Apr 29 2007