-static and dmd

Jonathan M Davis jmdavisProg at gmail.com
Sun Mar 28 09:15:15 PDT 2010


Mike Parker wrote:

> 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
> 
> Did you try passing -L-static to DMD?

Ah, thanks. Unfortunately, it doesn't work on my system at the moment. I get

/usr/bin/ld: cannot find -lgcc_s

However, that's probably more of an issue with my system missing stuff than 
there being a problem with dmd. It probably has to do with how horrid arch 
linux is with multilib. Still, it looks like I'm closer than I was. Thanks.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list