Compile a .so
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Sun Apr 29 03:31:30 PDT 2007
nobody at nowhere.nonet wrote:
> Sebastian <sebastian.faltoni at 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.
More information about the Digitalmars-d-learn
mailing list