Cent OS 7 Compile and install libc++ and Libc++abi

Source: Internet
Author: User

This article describes how to build the C++11 build environment in CentOS 7

Clang's Custom C + + library is libc++ (LIBCXX). then, Libcxx also needs an ABI library, Libc++abi (Libcxxabi). Unfortunately, the two libraries have a circular dependency problem. to break the cycle dependency problem, you can build libc++ without connecting to the Libc++abi. then, using this libc++, we can build Libc++abi link to libc++. Finally, using Libc++abi, we can build a new libc++ link to Libc++abi.

CMake and CLANG/LLVM installation please see

Http://www.cnblogs.com/BinBinStory/p/7461345.html

Http://www.cnblogs.com/BinBinStory/p/7499527.html

The Libc++,libc++abi build steps are as follows:

1. Get Libc++,libc++abi

    • Libc++ source code (. Sig)
    • Libc++abi source code (. Sig)

2. After the download, two are extracted, get two directories:

Libcxx-4.0.1.src

Libcxxabi-4.0.1.src

3. The first round of building libcxx does not require libcxxabi participation.

CD libcxx# It is not recommended to build Libcxxinchthe source root directory.# so, we Makea tmp directory.mkdirtmpcd tmp# specifying cmake_build_type to Release shall generate performance optimized code.# the Cmake_install_prefi X Changes theInstallPath from the default/usr/local to/Usr.cmake-dcmake_build_type=release-dcmake_install_prefix=/usr-dcmake_c_compiler=clang-dcmake_cxx_compiler=clang++ ..sudo  Make InstallCD..RMTMP-RFCD .

4. Build Libcxxabi libc++.

CD Libcxxabi mkdir  -dcmake_build_type=release-dcmake_install_prefix=/usr-dcmake_c_compiler=clang-dcmake_cxx_compiler= clang++-dlibcxxabi_libcxx_includes=. /.. /libcxx/include: sudo  Make Install CD.. /..

5. The 2nd round uses Libcxxabi to build Libcxx.

CD Libcxx mkdir  time, we want to compile libcxx with Libcxxabi, so we had to specifylibcxx_cxx_abi=-dcmake_bu ild_type=release-dcmake_install_prefix=/usr-dcmake_c_compiler=clang-dcmake_cxx_compiler=clang++-DLIBCXX_CXX_ Abi=libcxxabi-dlibcxx_cxx_abi_include_paths=. /.. /libcxxabi/include: sudo  Make Install

6. Write a C + + test program.

// t.cpp#include <iostream>usingnamespace  std; int Main () {  "Hello world! " << Endl;}

7. Test C + + compilation with clang++.

7 doesn't allow indirect library linking. clang++-std=c++ -stdlib=libc++-lc++abi T.cpp. /a.out

References:
[1] http://libcxx.llvm.org/
[2] http://libcxxabi.llvm.org/

Translated from: https://stackoverflow.com/questions/25840088/how-to-build-libcxx-and-libcxxabi-by-clang-on-centos-7

Cent OS 7 Compile and install libc++ and Libc++abi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.