开发者

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 w开发者_StackOverflow中文版ith 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


(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.


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}"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜