On my system I have 3 compilers installed. gcc-7.3.0, gcc-7.2.0, and clang-6.0
gcc-7.3.0 is installed to the system path and is the system default compiler.
gcc-7.2.0 is installed to /usr/local and is a build requirement for a specific tool.
clang-6.0 is installed to /usr/local and is used for it's stricter warnings/errors.
My boost libraries are compiled with gcc-7.2.0 and I wished to use clang to compile my specific tool. By default, with -stdlib=libstdc++
clang would find gcc-7.3.0 and boost would fail to link.
To get around this I used the following compile flags:
-stdlib=libstdc++ # Tell clang to parse the headers as libstdc++ not libc++
-cxx-isystem /usr/local/include/c++/7.2.0/ # includes for libstdc++
-cxx-isystem /usr/local/include/c++/7.2.0/x86_64-pc-linux-gnu/ # includes for libstdc
And the following linker flags:
-L/usr/local/lib64/ # static libstdc++
-L/usr/local/lib/gcc/x86_64-pc-linux-gnu/7.2.0/ #static libgcc
You can fill in your own linker paths with the directories that hold libstdc++.a
and libgcc.a
and these will depend on where your compiler is installed to.