今天忽然想玩一下Clang和LLVM,花了半天时间,终于搞定了,记录一下过程
- #下载LLVM源码到目录LLVM
- cd LLVM
- svn co http:///svn/llvm-project/llvm/trunk llvm
- #下载Clang源码到LLVM/llvm/tools
- cd llvm/tools
- svn co http:///svn/llvm-project/cfe/trunk clang
- #下载compiler-RT源码到LLVM/llvm/projects
- cd ../projects
- svn co http:///svn/llvm-project/compiler-rt/trunk compiler-rt
- #在目录LLVM下建一个编译目录build
- cd LLVM
- mkdir build
- cd build
- #配置安装
- ../llvm/configure --prefix=/usr/local/llvm --enable-optimized --enable-targets=host-only
- make -j2
- make install
然后就是漫长的编译过程。。
另外,在configure的时候出现了一点问题,说我gcc版本过低,需要gcc-4.7以上的版本,忽略之后在make的时候出现了"unrecognized command line option -std=c++11"的错误,于是只好先更新了一下gcc
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test
- sudo apt-get update
- sudo apt-get install gcc-4.8 g++-4.8
- #查看安装的gcc版本
- ls -lh /usr/bin/g++*
- #切换到gcc-4.8
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.4
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
- sudo update-alternatives --config gcc
参考文章
1
http://ilovers.sinaapp.com/article/centos%E4%B8%8B%E5%AE%89%E8%A3%85llvmclang
2
http://www.cnblogs.com/Frandy/archive/2012/10/20/llvm_clang_libcxx_cxx11.html
3 http://m.oschina.net/blog/226455
|