Linux: How to statically link against system libs?

Steven Schveighoffer schveiguy at yahoo.com
Tue Apr 26 12:10:06 PDT 2011


On Tue, 26 Apr 2011 14:49:56 -0400, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

>> On Linux, how do I get DMD to statically link against the necessary  
>> system
>> libs like libc?
>>
>> Someone suggested trying -L-static, but that just gives me this:
>>
>> /usr/bin/ld: cannot find -lgcc_s
>> collect2: ld returned 1 exit status
>> --- errorlevel 1
>
> http://d.puremagic.com/issues/show_bug.cgi?id=4376
>
> You're stuck, linking manually with gcc, which means copying all of the
> appropriate linker flags from dmd.conf. It also means that you don't get
> symbols in your stack traces for some reason (I've never been able to  
> figure
> out why). It does work though. Still, I'd love it if this bug could be  
> fixed.
> I hate dynamically linking anything if I can help it.

It's a bad idea to statically link libc.  This is from the glibc  
maintainer:

http://www.akkadia.org/drepper/no_static_linking.html

I don't think static linking is officially supported any more.

-Steve


More information about the Digitalmars-d-learn mailing list