I use clang++
for compiling C++ code. I link against the gcc
standard C++ library, libstdc++
. However, I have several different installation of libstdc++
on my Ubuntu machine. When I run clang++
, it uses the 4.8 installation of libstdc++
:
andy@andy:~$ clang++-3.5 -v
Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: i386-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.6
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.6.4
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Selected GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/4.8
Candidate multilib: .;@m32
Selected multilib: .;@m32
How can I tell clang++
to use a different version of the libstdc++
library and headers? specifically, I want to use the 4.6 version.
clang
? – Joegcc
4.8 is not installed, the same version ofclang
(specifically 3.4) usesgcc
4.6. So it is possible without using a different version ofclang
. – Mealy--gcc-toolchain=/path/to/gcc/prefix
command line option? As mentioned here, it should make Clang use specific version of GCC toolchain, including thelibstdc++
along withclang++
: "Clang will look within its own prefix for libstdc++ and use it if found. You can also add an explicit prefix for Clang to look in for a GCC toolchain with the --gcc-toolchain=/opt/my/gcc/prefix flag, passing it to both compile and link commands". – Enjoin