Clang與libc++abi庫安裝

系統ubuntu64位 Clang4.0html

參考:python

1 https://github.com/yangyangwithgnu/use_vim_as_ide#0.1ios

  其中 第7章 工具鏈集成c++

2. http://clang.llvm.org/get_started.html   git

  其中 Release Clang Versionsgithub

3. http://libcxxabi.llvm.org/ ubuntu

  其中 Get it and get involved!vim

先開始進行按照1中的方式單獨編譯 Clang/llvm以及相應的庫,在單獨編譯 libcxx以及libcxxabi庫,其中libcxxabi 編譯時報錯 :clang-4.0 link erroride

3中提出libcxx以及libcxxabi庫能夠集成或單獨編譯,因而在2中直接將libcxxabi庫直接包含在llvm/projects裏面,最後集成編譯整個項目。svn

最後用Clang++ 編譯後一下文件。

編譯源文件以下:

//new_feature.cpp
#include <iostream>
#include <string>

class MyClass
{
      public:
            std::string s ="Hello, world\n"; // Non-static data member initializer
};

int main()
{
      std::cout << MyClass().s;
}

編譯命令以下

clang++ -std=c++11 -stdlib=libc++ -Werror -Weverything -Wno-disabled-macro-expansion -Wno-float-equal -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-global-constructors -Wno-exit-time-destructors -Wno-missing-prototypes -Wno-padded -Wno-old-style-cast -lc++ -lc++abi new_feature.cpp

得出的a.out文件出現

./a.out: error while loading shared libraries: libc++abi.so.1: cannot open shared object file: No such file or directory

最後在編譯文件裏面將一下幾個庫添加至/usr/lib 裏面後得出輸出。

庫文件分別是:

libc++abi.so libc++abi.so.1 libc++abi.so.1.0 
libc++.so.1 libc++.so.1.0 libc++.so 

 

注意:可能須要將 build後生成的include裏面的頭文件手動拷貝到 /usr/include/c++/v1/ 裏面,爲了libc++以及libc++abi 的頭文件在查找目錄。

具體的命令以下:

  1. Get the required tools.
  2. Check out LLVM:
    • Change directory to where you want the llvm directory placed.
    • svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
  3. Check out Clang:
    • cd llvm/tools
    • svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
    • cd ../..
  4. Check out extra Clang tools: (optional)
    • cd llvm/tools/clang/tools
    • svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
    • cd ../../../..
  5. Check out Compiler-RT (optional):
    • cd llvm/projects
    • svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
    • cd ../..
  6. Check out libcxx: (only required to build and run Compiler-RT tests on OS X, optional otherwise)
    • cd llvm/projects
    • svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx
    • svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi
    • cd ../..  
  7. Build LLVM and Clang:
    • mkdir build (in-tree build is not supported)
    • cd build
    • cmake -G "Unix Makefiles" ../llvm
    • make
    • This builds both LLVM and Clang for debug mode.
    • Note: For subsequent Clang development, you can just run make clang.
    • CMake allows you to generate project files for several IDEs: Xcode, Eclipse CDT4, CodeBlocks, Qt-Creator (use the CodeBlocks generator), KDevelop3. For more details see Building LLVM with CMake page. 
相關文章
相關標籤/搜索