Dynamic loading of shared libraries.

Jens Mueller jens.k.mueller at gmx.de
Mon Jun 13 23:36:43 PDT 2011


Brad Roberts wrote:
> On Mon, 13 Jun 2011, Jens Mueller wrote:
> 
> > There have been some posts regarding support for shared libraries. On
> > top of my head there we're at least 5 things that need to be done to get
> > it working.
> > $ dmd -m64 -L-shared shared.d -oflibshared.so
> > /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o: relocation R_X86_64_32S against `__libc_csu_fini' can not be used when making a shared object; recompile with -fPIC
> > /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o: could not read symbols: Bad value
> > collect2: ld returned 1 exit status
> > --- errorlevel 1
> > 
> > I do not fully understand the error. But I believe there is something
> > wrong with dmd generating PIC.
> > 
> > Jens
> 
> When building a shared library, you must build with -fPIC.  That's likely 
> not sufficient to get it actually fully working with dmd.
> 
> so:  dmd -m64 -fPIC -L-shared shared.d -oflibshared.so

Yes. I actually built using -fPIC but pasted the wrong line. Anyway both
lines result in the same above error.

> That said, combining not-well-tested .so support with 64 bit is a good way 
> to discover new bugs, so go for it! :)

You say not-well-tested .so support. I thought it's still under
construction. I'm on dmd 2.053.

Jens


More information about the Digitalmars-d mailing list