Thread overview
Compile a .so
Apr 07, 2007
Sebastian
Apr 08, 2007
Clay Smith
Apr 29, 2007
nobody
Apr 29, 2007
Frits van Bommel
April 07, 2007
hi,
is possibile to compile .so for linux and for mac, with D? if true how i can do that?
thanks
April 08, 2007
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
April 29, 2007
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:

	# Creates foo.o
	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.
April 29, 2007
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:
> 
> 	# Creates foo.o
> 	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.