www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Using phobos as shared library for multiple binaries

reply Ralf <ralf nowhere.com> writes:
Hi,

I've written several small command-line utilities in D that are 
to be shipped together in one package. Each one of them only 
would be only a few kB in size, but they end up being ~1Mb, I 
assume because every one links statically parts of the standard 
library.

How can this be improved?

Are there binary builds of the standard library (for OS X) 
somewhere and an option to tell the compiler to link to this 
shared library?

Alternatively, is there a way to build a shared library that all 
the binaries can use together so they can share the common code?

Greetings,

Ralf
Dec 05 2015
next sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
On Saturday, 5 December 2015 at 21:49:52 UTC, Ralf wrote:
 I've written several small command-line utilities in D that are 
 to be shipped together in one package.
I'm not sure if shared lib support is on Mac or not (I know it is on Linux but mac is different...). But do they need to actually be separate executables? You could make them all one program and switch(args[0]) {} to see which name it was called by. Symlink all the various names to the one executable and the user will never know.
Dec 05 2015
prev sibling parent tcak <1ltkrs+3wyh1ow7kzn1k sharklasers.com> writes:
On Saturday, 5 December 2015 at 21:49:52 UTC, Ralf wrote:
 Hi,

 I've written several small command-line utilities in D that are 
 to be shipped together in one package. Each one of them only 
 would be only a few kB in size, but they end up being ~1Mb, I 
 assume because every one links statically parts of the standard 
 library.

 How can this be improved?

 Are there binary builds of the standard library (for OS X) 
 somewhere and an option to tell the compiler to link to this 
 shared library?

 Alternatively, is there a way to build a shared library that 
 all the binaries can use together so they can share the common 
 code?

 Greetings,

 Ralf
Some links for you: http://dlang.org/dmd-osx.html Check -defaultlib http://dlang.org/dll-linux.html This is for Linux, but check the last code example. It can help. I did what you ask in Linux, it works, but don't have knowledge about OS X.
Dec 05 2015