On Sunday, 16 March 2014 at 02:12:37 UTC, Carl Sturtivant wrote:
Back at 2.062 I was able to force the whole of D's
runtime/phobos into an executable which was exactly what I
wanted for a specific project containing not just D but around
50,000 lines of C. (This is to do with having dynamic libraries
link back to the executable when they're loaded with dlopen, so
they don't need their own runtime/phobos on board.) However, at
2.065 this doesn't happen any more. I need this same linkage
with 2.065. Previously I used
-Wl,--whole-archive -lphobos2 -Wl,--no-whole-archive
on a gcc command line to link all the objects in the project
along with libphobos2, with
-lcurl -lpthread -lm -lrt
to satisfy that linkage, and this had the desired effect. But
now this doesn't do the job of linking the whole of D's runtime
& phobos any more. Any suggestions how I can get the old result
with 2.065?
DMD started to support shared lib on linux from 2.063.
This may be useful: http://dlang.org/dll-linux.html
Also note that if you are only writting the shared lib and not
the client, it would be easyier to bootstrap it using gcc's
attributes (see
http://stackoverflow.com/questions/9759880/automatically-executed-functions-when-loading-shared-libraries
).
Else, there is a Runtime.loadLibrary (which will be improved
later), to load and start a D shared library (if you just dlopen,
static ctor & stuff won't be initialized).