Perhaps a kind person would help clear up my confusion regarding
-static-libgcc?

Consider the following C++ program:

------------ foo.cc -------------
using namespace std;

#include <cmath>

int main (int argc, char *argv[])
{
 int DIGITS;

   DIGITS=14;
   pow(1./10,DIGITS);
   return 0;
}
-------------------------------

Then

% g++ -o foo foo.cc
% foo
foo: /lib64/libgcc_s.so.1: version `GCC_4.0.0' not found (required by foo)
%

but

% g++ -static-libgcc -o foo foo.cc
% foo
%

Ok, I say to myself, I understand this.  The version of g++ that I am
using is one that I built in my home directory and so it's libgcc_s.so.1
is only linked if I use -static-libgcc.  Whereas without -static-libgcc,
I am linking with the system libgcc_s.so.1 that is older and for some
reason is not working.

However if I now do

% g++ -static-libgcc -o foo foo.cc
% foo
% ldd foo

I get

    libgcc_s.so.1 => /lib64/libgcc_s.so.1

which is the SYSTEM libgcc_s.so.1 and NOT the one
in my home directory:

    /home/kate/gcc-4.1.1/x86_64-Linux/lib64/libgcc_s.so.1

Is ldd lying to me?  Or am I totally misunderstanding -static-libgcc?

To add to my confusion, if I take out "using namespace std;" then
I get

% g++ -o foo foo.cc
% foo
%

Kate Minola
University of Maryland, College Park

Reply via email to