Install llvm and clang
Download llvm and clang source code. [http://releases.llvm.org/download.html#3.4.2]
//cfe-3.4.2 is clang3.4.2
$wget http://releases.llvm.org/3.4.2/cfe-3.4.2.src.tar.gz
$wget http://releases.llvm.org/3.4.2/llvm-3.4.2.src.tar.gzunzip and build LLVM and Clang.
$tar zxvf llvm-3.4.2.src.tar.gz
$tar zxvf cfe-3.4.2.src.tar.gz
//rename cfe-3.4.2.src to clang
$mv cfe-3.4.2.src clang
//move clang source code into llvm’s tools dir
$mv clang llvm-3.4.2.src/tools
$cd llvm-3.4.2.src
$mkdir build
$./configure –enable-optimized –enable-assertions –prefix=/home/jeremy/Tools/llvm-3.4.2.src/build$make
//$make check-all — This runs the regression tests to ensure everything is in working order.$make install
Configure the environment variable.
- Add the following two lines to the end of “~/.bashrc” file: (change the corresponding build pathname to your system)
export PATH=/home/jeremy/Tools/llvm-3.4.2/build/bin:$PATH export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/jeremy/Tools/llvm-3.4.2/build/lib
- $source ~/.bashrc
- Now, the commands such as “llvm-config” and “clang” should be available in command line.
(Those commands are in “llvm-3.4.2/build/bin” directory )
Reference:
http://clang.llvm.org/get_started.html
http://releases.llvm.org/3.4.2/docs/GettingStarted.html