且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

开发生产libc / libstdc ++不匹配[链接libc.so.6 / libstdc ++。so.6与旧版本]

更新时间:2023-02-02 21:10:12

使用 -static-libstdc ++ 选项编译应用程序。


I built an exec on C++, however when I deploy it to the deployment machine I find errors like :`

/lib64/libc.so.6: version GLIBC_2.14 not found /usr/lib64/libstdc++.so.6: version GLIBCXX_3.4.14 not found /usr/lib64/libstdc++.so.6: version CXXABI_1.3.5 not found

This turns out because the deployment machine is rhel based system with older libc(2.12)/libstdc++(3.4.13) while my machine is ubuntu with far recent kernel and libraries. Unfortunately I cannot upgrade the deployment system.

I tried some of the usual ways to handle this like static linking (libc fails) and copying my library versions to the cluster (and run with LD_PRELOAD and -Wl,--rpath options) , but it doesn't work.I also installed an older version of gcc on my machine, but that also doesn't work.

Is there some way I can get this to work (perhaps making object code on my local machine,and linking it on the other machine). Or is there a way to compile the code on the deployment machine without copying source to it. Could this work with getting a copy of system libraries from deployment machine and try to get gcc to link with them? (any issues with that, and how to do that correctly)

Related to Compile with older libc (version `GLIBC_2.14' not found) and Deploying Yesod to Heroku, can't build statically and Build and run C++ code on different version of Linux and glibc

I am aware of one way to do this via VM , but I want to avoid it if possible.(HT Mat)

Compile you application with -static-libstdc++ option.