CLion网站称他们支持“libc ++”,但没有关于如何设置CLlion以使用libc ++的信息。我正在使用Ubuntu 16并下载了libc ++源码并构建它。所以我想使用这个特定的版本。
这是我到目前为止所尝试的内容:
所以我现在有了libc ++二进制文件。然后我创建了简单的hello world项目并更改了它的CMakeLists.txt以使用我的自定义libc ++。但是,当我尝试运行该项目时,我收到错误:
/home/shitals/CLionProjects/JsonTest/cmake-build-debug/JsonTest: error while loading shared libraries: libc++.so.1: cannot open shared object file: No such file or directory
这是我的项目cmake强制使用我的自定义libc ++。
cmake_minimum_required(VERSION 3.8)
project(JsonTest)
set(CMAKE_CXX_STANDARD 14)
#libcxx which we will use with specific version of clang
SET(LIBCXX_INC_PATH /home/shitals/mylibc++/include/c++/v1)
SET(LIBCXX_LIB_PATH /home/shitals/mylibc++/lib)
set(CMAKE_C_COMPILER clang-3.9)
set(CMAKE_CXX_COMPILER clang++-3.9)
set(CMAKE_CXX_FLAGS "\
-std=c++14 -ggdb -Wall -Wextra -Wstrict-aliasing -Wunreachable-code -Wcast-qual -Wctor-dtor-privacy \
-Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default \
-Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-overflow=5 -Wswitch-default -Wundef \
-Wno-variadic-macros -Wno-parentheses -Wno-unused-function -Wno-unused -Wno-documentation -fdiagnostics-show-option -ferror-limit=10 \
-pthread ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "\
-nostdinc++ -isystem ${LIBCXX_INC_PATH} \
-D__CLANG__ ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "\
${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++ -lc++abi -lm -lc -lgcc_s -lgcc -ldl \
-L ${LIBCXX_LIB_PATH}")
set(SOURCE_FILES main.cpp)
add_executable(JsonTest ${SOURCE_FILES})
我编译的libc ++二进制文件确实有libc ++。so.1文件。
答案 0 :(得分:0)
好的......所以在项目根目录下的CMakeLists.txt下面似乎有效:
cmake_minimum_required(VERSION 3.8)
project(JsonTest)
set(CMAKE_CXX_STANDARD 14)
#libcxx which we will use with specific version of clang
SET(LIBCXX_INC_PATH /home/shitals/GitHubSrc/AirSim/llvm-build/output/include/c++/v1)
SET(LIBCXX_LIB_PATH /home/shitals/GitHubSrc/AirSim/llvm-build/output/lib)
set(CMAKE_C_COMPILER clang-3.9)
set(CMAKE_CXX_COMPILER clang++-3.9)
set(CMAKE_CXX_FLAGS "\
-std=c++14 -ggdb -Wall -Wextra -Wstrict-aliasing -Wunreachable-code -Wcast-qual -Wctor-dtor-privacy \
-Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default \
-Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-overflow=5 -Wswitch-default -Wundef \
-Wno-variadic-macros -Wno-parentheses -Wno-unused-function -Wno-unused -Wno-documentation -fdiagnostics-show-option -ferror-limit=10 \
-pthread ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "\
-nostdinc++ -isystem ${LIBCXX_INC_PATH} \
-D__CLANG__ ${CMAKE_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "\
${CMAKE_EXE_LINKER_FLAGS} -v -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc -ldl \
-L ${LIBCXX_LIB_PATH}")
LINK_DIRECTORIES(${LIBCXX_LIB_PATH})
set(SOURCE_FILES main.cpp)
add_executable(JsonTest ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(JsonTest c++ c++abi)