statically linked gcc executables

Andrew Haley aph@redhat.com
Fri Jan 25 03:51:00 GMT 2008


Angelo leto wrote:
> Hi, I'm trying to build statically all the gcc executables in order to
> generate a portable compiler package, in particular I need a package
> which is not dependent from a specific dynamic loader version
> (ld-linux.so.2), could you please help me to find a way to obtain
> this?
> For instance I can run gcc using the command "ld-linux.so.2
> ~/mygcc/usr/bin/c++", but c++ then calls cc1plus which also needs
> ld-linux.so.2 ....

The short answer is to set the makefile args to that gcc links with
-static.  Simply "make LDFLAGS=-static" might work for you.

The long answer:

Usually, people who want to do this don't know what they're doing, and
people who do know how to do it wouldn't consider doing it because
they know all the problems it will cause.

When you build gcc you're building it for a specific host/target
combination, and configure autodetects properties of both.  It doesn't
usually make much sense to use a gcc that's been built for one host on
a different host.

Sometimes, however, people build gcc on an old operating system
version and it will run on a newer version.  That makes sense for
cross-compilers, in particular.

So, can I ask you what you are really trying to do?  Is it that you
really need to run on some ancient Linux that really doesn't have
ld-linux.so.2?

Andrew.



More information about the Gcc-help mailing list