gpt4 book ai didi

libpqxx - 将 libpqxx 库添加到 cmake

转载 作者:行者123 更新时间:2023-12-04 00:30:40 25 4
gpt4 key购买 nike

我正在处理我的 C++ 简单项目,我在 CMakelists.txt 中遇到了一个关键问题,我无法以错误的方式链接 libpqxx 库,我花了两天时间解决了这个问题。
我正在使用 C++ 2017,
cmake 3.10 版,
操作系统 ubuntu 16.04,
克里昂
这是我的 CMakelists.txt

cmake_minimum_required(VERSION 3.10)
project(myserver)

set(CMAKE_CXX_STANDARD 17)

find_package(Boost)
IF (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
endif()

link_directories(/usr/local/lib)
include_directories(/usr/local/include)

file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")


add_executable(myserver ${SOURCE_FILES})


TARGET_LINK_LIBRARIES(myserver ${LIBRARIES})

提前致谢

最佳答案

我找到了解决方案。

   cmake_minimum_required(VERSION 3.10)

project(myserver)

set(CMAKE_CXX_STANDARD 17)

find_package(Boost)
IF (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lpqxx -lpq")

set(PQXX /usr/local/include/pqxx)

find_library(PQXX_LIB pqxx)
find_library(PQ_LIB pq)

file(GLOB_RECURSE SOURCE_FILES "src/*.cpp")


add_executable(myserver ${SOURCE_FILES})




TARGET_LINK_LIBRARIES(myserver ${PQXX_LIB} ${PQ_LIB})

谢谢

关于libpqxx - 将 libpqxx 库添加到 cmake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51633845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com