在Linux上将libc ++链接到CMake项目 [英] Linking libc++ to CMake project on Linux
问题描述
我想在CMake项目的Arch Linux上将libc ++和clang一起使用.我安装了libc ++,并按照 LLVM站点的Linux部分在Linux中使用libc ++您的程序":
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 "Using libc++ in your programs":
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "-lc++abi")
我在链接器的标志中仅尝试了"++ abi",但这没有帮助.我需要一些帮助来确定我应该在CMakeLists.txt中写些什么.
I have tried just "++abi" in linker's flags, but it didn't help. I need some help in figuring out what i should write in my CMakeLists.txt.
推荐答案
别忘了将编译器设置为clang ++:
Don't forget to set the compiler to clang++:
set(CMAKE_CXX_COMPILER "clang++")
此外,清除cmake生成的文件(删除文件夹CMakeFiles
和CMakeCache.txt
).
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")
这篇关于在Linux上将libc ++链接到CMake项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!