Originally the latest version is already 3.4, but, before the compilation once, failed, so this time first use 3.3
In addition this is reproduced the article
LLVM's latest version of 3.3 finally released on June 17, according to the previous plan June 5 should be released, but it is not too late to catch up with VS2013 preview (June 26 Microsoft Build conference) came out. Plus before gcc4.8.1 at the end of May June, today's top three C + + compilers are releasing important updates this month, and this June is a good day for C + +!
LLVM has been announced before the c++11 Feature complete, 3.3 should be the first stable version, before gcc4.8.1 is also full support c++11, this article describes how to compile on CentOS install the latest Gcc,vs has been a lot behind , but is still looking forward to VS2013 preview to increase the number of c++11 features.
LLVM3.3 offers a very rich pre-built Binaries including ubuntu13.04,ubuntu12.04 and Ubuntu10.04, as well as Debian6, FreeBSD9 and Fedora18, And, of course, Apple's own Mac OS X. Unfortunately, there is no pre-compiled version for CentOS, it can only be compiled and installed by itself.
Today, the latest version of the LLVM kit (Llvm,clang and libc++) is installed on CentOS, and there are a lot of problems in the middle. Although there are many blogs about how to compile and install LLVM, but according to my own experience of the situation, there is a place to pay attention to, there is something worth sharing with you.
The installation process mainly refers to these articles:
First, download the latest version from the http://llvm.org/releases/download.html#3.3 side. If you download the code from SVN, it is already a 3.4 development version, if you need to use a stable version, it is recommended to download 3.3 of the code package, you need to download 5 files:
LLVM Source Code
Clang Source Code
Clang Tools Extra Source code
Compiler RT Source Code
Libc++ Source Code
After the download, four compressed packets are extracted, get four directories:
Then follow these steps to organize:
mv cfe-3.3.src clang
mv clang/ llvm-3.3.src/tools/
mv clang-tools-extra-3.3.src extra
mv extra/ llvm-3.3.src/tools/clang/
mv compiler-rt-3.3.src compiler-rt
mv compiler-rt llvm-3.3.src/projects/
In this way Clang,clang-tools-extra and COMPILER-RT can be compiled together with LLVM.
Create a new directory on the LLVM-3.3.SRC same level directory build-3.3 and enter:
../llvm-3.3.src/configure --enable-optimized --enable-targets=host-only
Note : Here are two options recommended to add , otherwise it will produce huge files, when I first compile, did not add these two options, compiled the result of how big 9.4G(scary?) My disk is exhausted, also reported wrong, Google for a long time to find that the disk space is not enough), takemore than 1.5 hours, plus the results compiled later than the 1g,i5 four core 20 minutes more than the compilation completed.
Try to use as many cores as you can.
Then make install:
Use clang++-V to view the following:
Thread model: posix
At this point clang can be used normally,clang by default is the C + + library gcc libstdc++. Clang usage is similar to GCC, if you want to use C++11:
clang++ -std=c++11 [input]
If you want to use LLVM own libc++, you need the following steps (a little trouble):
Before entering the extracted LIBCXX-3.3.SRC:
Then you can see the libc++.so.1.0 file below the Libcxx-3.3.src/lib, which is libc++ 's dynamic library.
Follow the steps below to put libc++.so.1.0 under/usr/lib and create several links:
sudocp ./libc++.so.1.0 /usr/lib
sudoln -sf /usr/lib/libc++.so.1.0 libc++.so
sudoln -sf /usr/lib/libc++.so.1.0 libc++.so.1
Then copy the Libcxx-3.3.src/include directory to the/USR/INCLUDE/C++/V1 (this address is the clang default lookup directory, if the directory does not exist then create it yourself):
cp -r libcxx-3.3.src/include/ /usr/include/c++/v1
Supposedly, after that, it is possible to use libc++ in the following way:
clang++ -stdlib=libc++ -std=c++11 [input]
But when I compile this side, I am prompted to find the header file, need to manually add-i/usr/include/c++/v1/:
clang++ -stdlib=libc++ -std=c++11 -I/usr/include/c++/v1/ [input]
When running, the link error is also indicated: error while loading shared Libraries:libc++.so.1:cannot open Shared object File:no such file or director Y.
The workaround is to include the following environment variables in the ~/.basrch:
Restart the shell will be able to run normally, the above to find the header file and link errors are due to the use of libc++, if you use the default libstdc++ do not have these problems .
OK, although the use of a little trouble, but write a makefile do not have to knock so long command, enjoy!