Easily building a dynamic library with DMD
Jacob Carlborg
doob at me.com
Tue Apr 6 03:26:01 PDT 2010
Since I made modifications to Tango to work as a dynamic library on Mac
OS X I would now like DMD to be able to easily build dynamic libraries.
Building a dynamic library on Mac OS X with GCC is done like this:
gcc -dynamiclib files -o libdynamic.dylib
Trying to do the same with DMD causes some problems:
First try: using dmd and passing -dynamiclib to the linker. This will
fail since -dynamiclib is a gcc specific flag and not a linker flag.
When using the -dynamiclib flag the library is built with libtool and
not ld.
Second try: building with dmd and then linking with gcc. This will cause
the problem that I have to link to the D standard library when linking
with gcc and for that I have to know the path to the standard library. I
don't know if it is possible to get the path to the standard library.
I see three different solutions to this:
1. Add a -dylib flag, or similar, to dmd that will compile a dynamic
library.
2. Make it possible to pass flags to gcc and not just the linker with dmd.
3. Make it possible to get the path to the standard library with dmd.
The first option is the preferred option.
What do you think?
Any other suggestions to solve the problem?
/Jacob Carlborg
More information about the Digitalmars-d
mailing list