0

I have a custom build cmake v3.10.0 which was compiled with a gcc_4.8.3. I am using this custom build cmake to compile a cmake project that must use gcc _4.1.2 because of legacy code.

Executing cmake promted me with an error because it needs to use the libstdc++-IFX.so.6 provided by gcc_4.8.3 which I fixed by adding the path to the correct library in my LD_LIBRARY_PATH before the path to the libraries provided by gcc_4.1.2.

Compiling my project and linking an executable (which is done by c++) results in the linker taking the gcc_4.8.3 stdlibs over the gcc_4.1.2 libs. Is there any way to tell cmake to not use the libraries it needs for himself for my cmake project preferably without touching LD_LIBRARY_PATH?

Edits:

@squareskittles comment: I did read and try everything this post suggest but without any changes. The libstdc++-IFX.so.6 is still taken from gcc_4.8.3

HFinch
  • 534
  • 1
  • 7
  • 20
  • Have a look at this [post](https://stackoverflow.com/questions/6581357/linking-to-stdc-with-cmake-and-gcc-4-1-2). You can set the `CC` and `CXX` variables. Or you can edit your CMake file(s) to manually add the libstdc++ library from the older compiler using `target_link_libraries`. – Kevin Jul 24 '19 at 12:16
  • Can you provide more details about your build system? – nega Jul 25 '19 at 16:08
  • Also, have you tried adding `-static-libstdc++` to your CXX_FLAGS or CMAKE_CXX_FLAGS? – nega Jul 25 '19 at 16:13
  • @nega yes I did try to add `-static-libstdc++` to my cxx flags but this has no effect. What do you want to know abut the build system ? primarily standard gcc 4.1.2 – HFinch Jul 26 '19 at 10:09
  • OS? Linux? if so, what distro? how are the compilers installed? do you have `root`? – nega Jul 27 '19 at 03:00
  • have you tried building your cmake with `-static-libstdc++` and then wiping your gcc_4.8.3 chain? – nega Jul 27 '19 at 03:01
  • RHEL 5, compilers are preinstalled and no i do not have permanent root access. When i build cmake i followed the instructions given by https://gitlab.kitware.com/cmake/cmake/tree/v3.13.4 i am not sure if i have the possibility to use `-static-libstdc++` – HFinch Jul 29 '19 at 06:35

0 Answers0