Linking libc++ to CMake project on Linux

后端 未结 2 1695
心在旅途
心在旅途 2021-02-13 10:54

I want to use libc++ together with clang on Arch Linux in CMake project. I installed libc++ and added following lines to CMakeLists.txt as said on LLVM site in Linux section of

2条回答
  •  南旧
    南旧 (楼主)
    2021-02-13 11:48

    Don't forget to set the compiler to clang++:

    set(CMAKE_CXX_COMPILER "clang++")
    

    Also, purge the cmake generated files (delete the folder CMakeFiles and CMakeCache.txt).

    Depending on your system, it might also help to set

    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
    

提交回复
热议问题