Binding libC ++ to the CMake project on Linux

I want to use lib ++ with clang on Arch Linux in a CMake project. I installed lib ++ and added the following lines to CMakeLists.txt, as stated on the LLVM site in the Linux section "Using lib ++ in your programs":

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++") set(CMAKE_EXE_LINKER_FLAGS "-lc++abi") 

I tried just "++ abi" in the linker flags, but that didn't help. I need help figuring out what I should write in my CMakeLists.txt.

+5
source share
1 answer

I would add this as a comment, but I do not have enough reputation.

Remember to install the compiler in clang ++:

 set(CMAKE_CXX_COMPILER "clang++") 

Also clean the created cmake files (delete the CMakeFiles and CMakeCache.txt ).

Depending on your system, this may also help to install

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

Source: https://habr.com/ru/post/1207848/


All Articles