C++ 如何修复“/lib/tls/libc.so.6: version `GLIBC_2.4' not found”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/920485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 17:57:16  来源:igfitidea点击:

How to fix "/lib/tls/libc.so.6: version `GLIBC_2.4' not found"?

c++linker

提问by amit

I compiled a binary and copied on another machine for execution. But I am getting the above error. On the second machine, I cannot install new libraries. I tried putting the libc from the first machine into the directory of the binary on the second machine, but the linker (as I found using ldd) still loads from the standard path /lib/tls/libc.so.6). Please let me know a least change fix for this.

我编译了一个二进制文件并复制到另一台机器上执行。但我收到上述错误。在第二台机器上,我无法安装新的库。我尝试将第一台机器上的 libc 放入第二台机器上的二进制目录,但链接器(如我使用 ldd 发现的)仍然从标准路径 /lib/tls/libc.so.6 加载。请让我知道对此的最小更改修复。

Update:

更新:

Command used for compilation/linking:

用于编译/链接的命令:

g++ -O2 -DNDEBUG -o CountStrings -I../../../../../tbb/tbb20_20080408oss_src/include/ ../src/CountStrings.cpp -L../../../../../tbb/tbb20_20080408oss_src/build/linux_ia32_gcc_cc4.3.2_libc2.8.90_kernel2.6.27_release/ -ltbb

g++ -O2 -DNDEBUG -o CountStrings -I../../../../../tbb/tbb20_20080408oss_src/include/../src/CountStrings.cpp -L../../../ ../../tbb/tbb20_20080408oss_src/build/linux_ia32_gcc_cc4.3.2_libc2.8.90_kernel2.6.27_release/-ltbb

libtbb.so has dependency on libc.so.6

libtbb.so 依赖于 libc.so.6

回答by Samoht

In fact the easier way to fix the issue is to upgrade your OS version.

事实上,解决问题的更简单方法是升级您的操作系统版本

For example, Java 1.7 is not running on RedHat 4 but works well on RedHat 5.

例如,Java 1.7 不在 RedHat 4 上运行,但在 RedHat 5 上运行良好。

回答by AngryWhenHungry

Try exporting LD_LIBRARY_PATH=<location_of_your_lib>for your process
e.g. $ LD_LIBRARY_PATH=/home/kumar ./a.out
will look for libs in /home/kumar/before anywhere else

尝试LD_LIBRARY_PATH=<location_of_your_lib>为您的进程导出,
例如$ LD_LIBRARY_PATH=/home/kumar ./a.out
/home/kumar/在其他任何地方之前查找库

回答by lothar

I am not sure what (ill) side effects it may have to use another libc than provided by the system, but you can try to force using your special libc copy with LD_PRELOAD

我不确定使用另一个系统提供的 libc 可能有什么(生病的)副作用,但是您可以尝试强制使用带有LD_PRELOAD 的特殊 libc 副本

LD_PRELOAD=<location_of_your_lib> <yourprogram>

回答by tvanfosson

Have you checked to see if there is a static version of the library on the compilation machine? If there is you could explicitly link against it, using /lib/tls/libc.a instead of -L/lib/tls -lc (or whatever your dialect is).

有没有检查编译机上有没有静态版本的库?如果有,您可以明确链接它,使用 /lib/tls/libc.a 而不是 -L/lib/tls -lc (或任何您的方言)。