[cfe-users] installing a complete clang++ environment
Eugene Golovachev
kamelusz at yandex.ru
Fri Sep 26 10:21:11 PDT 2014
I perform the next steps to get working Clang and libc++ on my Gentoo box:
1) Download packages llvm-3.5.0.src.tar.xz, lldb-3.5.0.src.tar.xz,
libcxx-3.5.0.src.tar.xz, libcxxabi-3.5.0.src.tar.xz,
compiler-rt-3.5.0.src.tar.xz, cfe-3.5.0.src.tar.xz,
clang-tools-extra-3.5.0.src.tar.xz from http://llvm.org/releases/
2) Extract them:
$ mkdir -pv ~/src/llvm/release_35
$ tar xfv llvm-3.5.0.src.tar.xz --strip-components=1 -C
~/src/llvm/release_35/
$ mkdir -pv ~/src/llvm/release_35/projects/{libcxx,libcxxabi,compiler-rt}
$ tar xfv libcxx-3.5.0.src.tar.xz --strip-components=1 -C
~/src/llvm/release_35/projects/libcxx/
$ tar xfv libcxxabi-3.5.0.src.tar.xz --strip-components=1 -C
~/src/llvm/release_35/projects/libcxxabi/
$ tar xfv compiler-rt-3.5.0.src.tar.xz --strip-components=1 -C
~/src/llvm/release_35/projects/compiler-rt/
$ mkdir -pv ~/src/llvm/release_35/tools/{clang,lldb}
$ tar xfv cfe-3.5.0.src.tar.xz --strip-components=1 -C
~/src/llvm/release_35/tools/clang/
$ tar xfv lldb-3.5.0.src.tar.xz --strip-components=1 -C
~/src/llvm/release_35/tools/lldb/
$ mkdir -pv ~/src/llvm/release_35/tools/clang/tools/extra
$ tar xfv clang-tools-extra-3.5.0.src.tar.xz --strip-components=1 -C
~/src/llvm/release_35/tools/clang/tools/extra/
3) And compile using cmake and Clang 3.3 from Gentoo portages:
$ mkdir -pv ~/build
$ cd ~/build
$ CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake
-DCMAKE_INSTALL_PREFIX=~/opt/clang-3.5.0-release/
-DCMAKE_BUILD_TYPE=Release ~/src/llvm/release_35/
$ make -j3
$ make install
4) As result I have working Clang with libc++ support. For linking with
libc++ it necessary to set LD_LIBRARY_PATH environment variable:
$ export LD_LIBRARY_PATH=~/opt/clang-3.5.0-release/lib/
And now I can use Clang with libc++:
$ ~/opt/clang-3.5.0-release/bin/clang++ -stdlib=libc++ -nodefaultlibs
-lc++ -lc++abi -lm -lc -lgcc_s -lgcc main.cpp
$ ./a.out
Hello off, world!
PS: sorry for my English :(
On 09/26/2014 12:43 PM, Klaus Rudolph wrote:
> I try to use clang 3.6 for c++ development. I found a "clang+llvm-3.5.0-x86_64-fedora20.tar.xz" binary. But compiling with it results in:
>
> ...
> /usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../include/c++/4.8.3/cstdio:120:11: error: no member named 'gets' in the global namespace
> ...
>
> which shows that clang uses my system installed stdlibc++ which is not what I want.
>
> After searching a lot I found that I should set:
> CXXFLAGS=-stdlib=libc++ -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc
>
> which simply results in:
> /usr/bin/ld: cannot find -lc++
> /usr/bin/ld: cannot find -lc++abi
>
> OK, both libs are not part of the binary prebuild.
>
> Where can I find the needed libraries? If not, how can I compile a complete clang++? And how to install them?
>
> Is there any full documentation about clang installing and first steps for using tutorial?
>
> My problem is that I could find a lot of information, but nothing is complete. Each page I found give only a piece of information and combining all the infos results in incompatible solutions.
>
> Regards!
> Klaus
>
>
>
> _______________________________________________
> cfe-users mailing list
> cfe-users at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
More information about the cfe-users
mailing list