简体   繁体   English

g ++和libstdc ++

[英]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. 在/ usr / lib下安装了libstdc ++(旧)的redhat 4机器,并将旧版本的gcc安装到默认位置。

We also have a newer version of gcc 4.4.5 installed in a different directory with a newer version of libstdc++. 我们还将更新版本的gcc 4.4.5安装在不同的目录中,并使用较新版本的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++. 当我使用4.4.5构建程序并尝试运行时,我得到错误,表明我使用的是旧版本的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. 有没有办法可以在/ usr / lib上安装系统libstdc ++而不是它附带的系统上建立新的编译器链接。

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. 似乎gcc与其标准包含和标准库密切相关。 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. 他们的修补程序甚至在gcc可执行文件中进行了硬编码,因此gcc vX应该自动选择其自身构建的相应文件(包括+标准库)(构建之前的./configure命令中的选项--prefix),除非重写。

The gcc standard C++ lib is shipped with gcc and built with the same command. gcc标准C ++ lib随gcc一起提供,并使用相同的命令构建。

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++? 为什么要将新编译器链接到旧的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. 在LD_LIBRARY_PATH中指定路径。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM