-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't compile in Centos7 environment #645
Comments
in addition, my envirnoment is: |
The simplest if you're using cmake is to add pqxx as a subdirectory:
And then use |
But you also have a load of other things. You only need the |
this time,i simplify my CMakeLists.txt except things for importing workflow cmake_minimum_required (VERSION 3.8)
project ("CMPlatformServer" LANGUAGES CXX)
MESSAGE(STATUS "Project Directory: ${PROJECT_SOURCE_DIR}")
include_directories(
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/server
${PROJECT_SOURCE_DIR}/third/workflow/_include/
)
file(GLOB_RECURSE CODE_SRC "${PROJECT_SOURCE_DIR}/src/*.h"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/server/*.h"
"${PROJECT_SOURCE_DIR}/src/server/*.cpp")
add_subdirectory(${PROJECT_SOURCE_DIR}/third/workflow)
add_subdirectory(${PROJECT_SOURCE_DIR}/third/libpqxx)
add_executable (CMPlatformServer ${CODE_SRC})
target_link_libraries(CMPlatformServer
PRIVATE workflow-static pqxx pthread ssl crypto
) |
The error is reported because the PostgreSQL library installed on the machine is missing. libpqxx depends on the PostgreSQL library, so PostgreSQL must be installed on your machine. |
You'll also need the development packages. Depending on the distribution they can have different names. Maybe something like |
Note also that CMake automatically detects PostgreSQL libraries only for PostgreSQL versions that have been released at the time CMake is released. See also: #624 (comment) |
thank you very much, i have solved this problem by adding "set(PostgreSQL_ROOT "/usr/pgsql-14")"
it seems like cmake don't find target pqxx |
The error makes it look like it's not understanding that |
this is my CMakeLists.txt cmake_minimum_required (VERSION 3.8)
project ("CMPlatformServer" LANGUAGES CXX)
set(CMAKE_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -g -Werror=return-type")
add_definitions(-std=c++11)
MESSAGE(STATUS "Project Directory: ${PROJECT_SOURCE_DIR}")
set(PostgreSQL_ROOT "/usr/pgsql-14")
link_directories()
include_directories(
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/server
${PROJECT_SOURCE_DIR}/third/workflow/_include/
${PROJECT_SOURCE_DIR}/third/libpqxx/include/
)
file(GLOB_RECURSE CODE_SRC "${PROJECT_SOURCE_DIR}/src/*.h"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/server/*.h"
"${PROJECT_SOURCE_DIR}/src/server/*.cpp")
add_subdirectory(${PROJECT_SOURCE_DIR}/third/workflow)
add_subdirectory(${PROJECT_SOURCE_DIR}/third/libpqxx)
add_executable (CMPlatformServer ${CODE_SRC})
target_link_libraries(CMPlatformServer
PRIVATE workflow-static pqxx pthread ssl crypto
) |
in build/third/libpqxx/CMakeFiles directory, it doesn't create a .so or .a lib file |
If third-party libraries are imported with You need to remove the CMake build directory once, because CMake generates a cache of variables in the build directory, and the old cache causes the |
i understand what you said
but i notice that it does't build pqxx target before link CMPlatformServer target; but another thirdpart target called workflow has built successfully cmake_minimum_required (VERSION 3.8)
project ("CMPlatformServer" LANGUAGES CXX)
add_definitions(-std=c++11)
MESSAGE(STATUS "Project Directory: ${PROJECT_SOURCE_DIR}")
set(PostgreSQL_ROOT "/usr/pgsql-14")
include_directories(
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/server
${PROJECT_SOURCE_DIR}/third/workflow/_include/
${PROJECT_SOURCE_DIR}/third/libpqxx/include/
)
file(GLOB_RECURSE CODE_SRC "${PROJECT_SOURCE_DIR}/src/*.h"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/server/*.h"
"${PROJECT_SOURCE_DIR}/src/server/*.cpp")
add_subdirectory(${PROJECT_SOURCE_DIR}/third/workflow)
add_subdirectory(${PROJECT_SOURCE_DIR}/third/libpqxx)
add_executable (CMPlatformServer ${CODE_SRC})
target_link_libraries(CMPlatformServer
PRIVATE workflow-static pthread ssl crypto
PRIVATE pqxx
) |
You can see in the build output that it isn't building pqxx. Maybe the extra |
I turn to version7.6 and switch c++ compile version to C++17. and finally success! 🎉🎉 thank you so much to help me solve problems 😘😘 |
I am not a native specker, Please forgive me。
I want to add libpqxx as a third part dependence by CMake。but when i use "cmake .." to compile, there are something wrong like this:
here is my project structure:
and here is my CMakeLists.txt:
how can i currently import libpqxx by CMake?
The text was updated successfully, but these errors were encountered: