我正在尝试编译我的程序,该程序需要功能和比目标计算机上安装的C++11
更新版本。boost
因此,我使用所有依赖项和 binutils 的树内构建进行编译并安装gcc 4.9
到某个本地目录 ( )。/secured/local
然后我下载boost 1.55
并运行./boostrap.sh --prefix=/secured/local && ./b4 install
安装boost。两种编译都运行良好并且gcc -std=c++11
也有效。
FindXX.cmake
我的程序是使用 cmake 和查找文件的常规过程构建的。我像这样运行 cmake:
cmake ../source/ -DBOOST_ROOT=/secured/local -DCMAKE_EXE_LINKER_FLAGS='-Wl,-rpath,/secured/local/lib'
它成功找到了我的新安装的 boost 和新版本的 gcc。编译和链接都可以完美地工作。但是,在执行我的程序时,我收到以下错误:
$ ./surface
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./surface)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by ./surface)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ./surface)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by ./surface)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /secured/local/lib/libconfig++.so.9)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /secured/local/lib/libboost_program_options.so.1.55.0)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /secured/local/lib/libboost_program_options.so.1.55.0)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /secured/local/lib/libboost_program_options.so.1.55.0)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /secured/local/lib/libboost_filesystem.so.1.55.0)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /secured/local/lib/libboost_regex.so.1.55.0)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /secured/local/lib/libboost_regex.so.1.55.0)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by /secured/local/lib/libboost_regex.so.1.55.0)
./surface: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /secured/local/lib/libboost_regex.so.1.55.0)
objdump
在增强显示上运行
objdump -x /secured/local/lib/libboost_program_options.so.1.55.0 | grep stdc++
NEEDED libstdc++.so.6
required from libstdc++.so.6:
看起来好像两个 boost 库都尝试/usr/lib64/libstdc++.so.6
在/secured/local/lib
.我在程序中做错了什么?
请注意,我尽量避免设置LD_LIBRARY_PATH
某处。
答案1
安装gcc
会将 alibstdc++.so.6
放入 和$PREXIF/lib
中$PREFIX/lib64
。使用后者作为RPATH
升压,我的程序解决了这个问题。仅使用前者会导致回退到系统libstdc++.so.6
。