[Issue 4080] New: Patch for building dynamic libraries on Mac OS X
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 11 05:48:53 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4080
Summary: Patch for building dynamic libraries on Mac OS X
Product: D
Version: future
Platform: x86
OS/Version: Mac OS X
Status: NEW
Severity: normal
Priority: P2
Component: druntime
AssignedTo: sean at invisibleduck.org
ReportedBy: doob at me.com
--- Comment #0 from Jacob Carlborg <doob at me.com> 2010-04-11 05:48:49 PDT ---
Created an attachment (id=606)
Adds the "-dylib" flag
These three patches adds support for building dynamic libraries on Mac OS X.
The patch for DMD adds the "-dylib" flag to the compiler. Building with this
flag enabled will produce a dynamic library.
The patch for druntime makes the necessary changes to build dynamic libraries.
The D main function is now weakly linked, all of the module constructors of all
the loaded images (executables, dynamic libraries) are run. The C main function
is slightly modified to use the rt_init and rt_term functions. Two C functions
are also added the will initialize and terminate the runtime if no D main
function is available, i.e. a D plugin linked with a C application.
The patch for phobos is just some modifications to the make file.
To build druntime and phobos as dynamic libraries add "dynamic", i.e. "make -f
osx.mak dynamic".
A note about dynamic libraries on Mac OS X:
Every dynamic library has an install name on Mac OS X which is the path to
where an executable should look for the library when loading it. The build
script sets this to "@rpath/<libname>.dylib", where <libname> is "libdruntime"
or "libphobos2".
@rpath is a relative path which the user can set when compiling an executable
like this: "dmd -L-rpath -L/path/to/library/". When the executable then is
loaded it will search for the library in "/path/to/library/<libname>.dylib".
-rpath can be set multiple times. The user can also change the install name
with the tool "install_name_tool" without needing to recompile.
A change to the dmd.conf file is also needed. With this change the user doesn't
have to set the @rpath every time when compiling. "libdruntime" must also be
linked.
DFLAGS=-I%@P%/../src/phobos -I%@P%/../src/druntime/import -L-L%@P%/../lib
-L-rpath -L%@P%/../lib -L%@P%/../lib/libdruntime.dylib
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list