-static and dmd

Robert Clipsham robert at octarineparrot.com
Sun Mar 28 04:35:32 PDT 2010

On 28/03/10 10:28, Jonathan M Davis wrote:
> With gcc, you can pass it the -static flag and it will statically link
> everything. Normally, with dmd (on linux at least), it dynamically links all
> of the C/C++ libraries that it uses. So, if I run ldd (well, ldd32
> technically) on one of my programs I get:
>          linux-gate.so.1 =>   (0xf7794000)
>          libpthread.so.0 =>  /lib32/libpthread.so.0 (0xf7756000)
>          libm.so.6 =>  /lib32/libm.so.6 (0xf7730000)
>          libc.so.6 =>  /lib32/libc.so.6 (0xf75ea000)
>          /lib32/ld-linux.so.2 (0xf7795000)
> If it were gcc and -static had been used, you'd get
>          not a dynamic executable
> I'd like to be able to do the equivalent of -static with dmd so that my dmd-
> generated binaries don't have to link against any of the C/C++ libraries on
> my system. Is there a way to do that? I can't see any. Certainly, none of
> dmd's options appear to give that kind of functionality. So, if there is a
> way to do it, I'd like to know how. Does anyone here know how?
> - Jonathan M Davis

I don't think dmd offers a way to do this by default, your best bet 
would be to add -static to the makefile and see how it goes.

More information about the Digitalmars-d-learn mailing list