How to create shared library on linux?

Anders Runesson anders at
Mon Aug 14 05:42:11 PDT 2006

sön 2006-08-13 klockan 18:31 +0000 skrev Li Jie:
> I dont know how to create a shared library using dmd or build(
> I try to compile the D source files to .o, and link them:
> # dmd -c *.d
> # gcc -o -shared *.o -lphobos

Try adding the -fPIC flag, like so:
gcc -o -shared -fPIC *.o -lphobos

don't forget that libraries need to be named for the
linker to find them. (Note the "lib" in the beginning of the file name)


More information about the Digitalmars-d-learn mailing list