tworivers
tworivers

Reputation: 57

g++ and libstdc++

I have the following setup.

A redhat 4 machine with libstdc++ (old) installed under /usr/lib and an older version of gcc installed to the default location.

We also have a newer version of gcc 4.4.5 installed in a different directory with a newer version of libstdc++.

When I build a program with 4.4.5 and try to run I get errors indicating that I am using an older version of libstdc++.

Is there a way I can make the new compiler link against the system libstdc++ installed at /usr/lib instead of the one it comes with.

Thanks in advance

Upvotes: 3

Views: 838

Answers (2)

Offirmo
Offirmo

Reputation: 19840

(I know it's an old question, this is for fellow googlers)

It seems that gcc is closely tied to its standard includes and standard lib. Their pathes are even hardcoded in gcc executables so gcc vX should automatically pick its corresponding files (includes + standard lib) that were built alongst itself (option --prefix in the ./configure command before the build) unless overriden.

The gcc standard C++ lib is shipped with gcc and built with the same command.

So it is not possible/recommanded to use non matching standard lib and compiler versions, unless with luck if the changes are minor.

Upvotes: 3

Mark Loeser
Mark Loeser

Reputation: 18627

Why do you want the new compiler to link against the old libstdc++? The problem sounds like its the new compiler using the old library already because it doesn't know where its is. Specify the path in LD_LIBRARY_PATH.

export LD_LIBRARY_PATH="/path/to/my/new/lib:${LD_LIBRARY_PATH}"

Upvotes: 1

Related Questions