I am trying to compile a program of mine, that needs C++11 features and a newer version of boost than is installed on the target machine. I therefore compiled and installed gcc 4.9 to some local directory (/secured/local) with an in-tree build of all dependencies and the binutils. I then downloaded boost 1.55 and ran ./boostrap.sh --prefix=/secured/local && ./b4 install to install boost. Both compilations worked fine and gcc -std=c++11 also works.

My program is built using cmake with the usual FindXX.cmake procedure of finding files. I am running cmake like this:

cmake ../source/ -DBOOST_ROOT=/secured/local -DCMAKE_EXE_LINKER_FLAGS='-Wl,-rpath,/secured/local/lib'

which successfully finds my new boost installation and the new version of gcc. Compilation and linking both work flawlessly. However, upon execution of my program I am getting the following errors:

$ ./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)

Running objdump on boost shows

objdump -x /secured/local/lib/libboost_program_options.so.1.55.0 | grep stdc++
  NEEDED               libstdc++.so.6
  required from libstdc++.so.6:

It appears as if both the boost libs try to use the old /usr/lib64/libstdc++.so.6 instead the new one in /secured/local/lib. What did I do wrong in my procedure?

Note, that I try to avoid setting the LD_LIBRARY_PATH somewhere.

  • What distribution, please? – Faheem Mitha Jun 3 '14 at 13:41
  • Some old CentOS with Linux 2.6.18. I do not have root access. – janoliver Jun 3 '14 at 13:44
  • @janoliver stackoverflow.com/questions/2726993/… – vfbsilva Jun 3 '14 at 13:57
  • @vfbsilva: As you can see, I am using the rpath way of specifying the lib directory - doesn't work. Executing my program with LD_LIBRARY_PATH=/secured/local/lib also doesn't work. – janoliver Jun 3 '14 at 14:00
  • @janoliver strange, does your user has access rights over the library folder? – vfbsilva Jun 3 '14 at 14:02
up vote 10 down vote accepted

Installing gcc puts a libstdc++.so.6 into both $PREXIF/lib and $PREFIX/lib64. Using the latter as RPATH for boost and my program solved the issue. Using only the former results in a fall-back to the system libstdc++.so.6.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.