statically linked gcc executables

Andrew Haley
Fri Jan 25 13:17:00 GMT 2008

Angelo Leto wrote:
> On Jan 24, 2008 5:12 PM, Andrew Haley <> wrote:
>> Angelo Leto wrote:
>>> On Jan 24, 2008 12:18 PM, Andrew Haley <> wrote:
>>>> 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
>>>>> (, could you please help me to find a way to obtain
>>>>> this?
>>>>> For instance I can run gcc using the command "
>>>>> ~/mygcc/usr/bin/c++", but c++ then calls cc1plus which also needs
>>>>> ....
>>>> The short answer is to set the makefile args to that gcc links with
>>>> -static.  Simply "make LDFLAGS=-static" might work for you.
>>> I already tried this, but seems not to work.
>> It works for me.  You need to tell us in what way it seems not to
>> work for you.  We can't get far by guessing.
> The steps I execute are:
> 1) I downloaded gcc-4.2.2 from
> 2) enter gcc-4.2.2
> 3) make LDFLAGS=-static
> 4)  /usr/local/src/gcc-4.2.2 # ldd host-i686-pc-linux-gnu/gcc/cc1plus
> =>  (0xffffe000)
> => /lib/ (0xb7e94000)
>         /lib/ (0xb7fdd000)

That's odd, because when I tried it, it worked.  Perhaps because I built
without bootstrapping.  Maybe it's because you're building a different
version of gcc.

If you go into the gcc dir,

  # rm cc1plus
  # make cc1plus LDFLAGS=-static

what happens?

I do sympathize, but I think you're doing the wrong thing.  Yes, you are
going to have to have two versions of your gcc binaries, one with and one with, but that should be all.


More information about the Gcc-help mailing list