Libpqxx使用CMake的未定义引用

问题描述 投票:0回答:1

我在WSL工具栈中使用CLion(强制CMake)。

cmake_minimum_required(VERSION 3.13)
project(conana)

set(CMAKE_CXX_STANDARD 20)
include(${CMAKE_BINARY_DIR}/cmake-build-debug/conanbuildinfo.cmake)
conan_basic_setup()
set(APPEND CMAKE_PREFIX_PATH "/mnt/c/Users/b/src/libpqxx/")

set(SOURCES main.cpp)

add_executable(conana ${SOURCES})
#target_link_libraries(${project} ${CONAN_LIBS})

产生错误

====================[ Build | conana | Debug ]==================================
/usr/bin/cmake --build /mnt/c/Users/b/CLionProjects/conana --target conana -- -j 8
[ 50%] Building CXX object CMakeFiles/conana.dir/main.cpp.o
[100%] Linking CXX executable bin/conana
/usr/bin/ld: CMakeFiles/conana.dir/main.cpp.o: in function `__static_initialization_and_destruction_0(int, int)':
/home/buddha/.conan/data/libpqxx/7.0.1/bincrafters/stable/package/cfd7bc19fdc01c984df6e1fe4e7d6856d5f9b76a/include/pqxx/strconv.hxx:76: undefined reference to `pqxx::internal::demangle_type_name[abi:cxx11](char const*)'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/conana.dir/build.make:84: bin/conana] Error 1
make[2]: *** [CMakeFiles/Makefile2:73: CMakeFiles/conana.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/conana.dir/rule] Error 2
make: *** [Makefile:118: conana] Error 2

感谢您的帮助。取消注释target_link_libraries会出现“不受此CMake管理”错误。

cmake clion windows-subsystem-for-linux conan libpqxx
1个回答
0
投票

最终删除了柯南,并完成了libpqxx问题here中的解决方案。 CMakeLists.txt最终是

cmake_minimum_required(VERSION 3.13)
project(conana)

set(CMAKE_CXX_STANDARD 20)

find_library(PQXX_LIB pqxx REQUIRED)
find_library(PQ_LIB pq REQUIRED)

set(SOURCES main.cpp)

add_executable(conana ${SOURCES})
TARGET_LINK_LIBRARIES(conana ${PQXX_LIB} ${PQ_LIB})

这在连接后也立即解决了一些问题。希望这对某人有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.