microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.18k stars 6.39k forks source link

can't link libpqxx on linux ubuntu #6268

Closed pahan76 closed 4 years ago

pahan76 commented 5 years ago

Package: libpqxx:x64-linux Vcpkg version: 2018.11.23-unknownhash

pavels@crab:~/dev/cpp/test/release$ ../../cmake .. -DCMAKE_TOOLCHAIN_FILE=/home/pavels/dev/cpp/vcpkg/scripts/buildsystems/vcpkg.cmake
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Current source dir /home/pavels/dev/cpp/test
-- set project test
CMake Warning at /home/pavels/dev/cpp/vcpkg/scripts/buildsystems/vcpkg.cmake:234 (_find_package):
  By not providing "Findlibpqxx.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "libpqxx", but
  CMake did not find one.

  Could not find a package configuration file provided by "libpqxx" with any
  of the following names:

    libpqxxConfig.cmake
    libpqxx-config.cmake

  Add the installation prefix of "libpqxx" to CMAKE_PREFIX_PATH or set
  "libpqxx_DIR" to a directory containing one of the above files.  If
  "libpqxx" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  src/CMakeLists.txt:12 (find_package)

-- Configuring done
-- Generating done
-- Build files have been written to: /home/pavels/dev/cpp/test/release

Output errors:

pavels@crab:~/dev/cpp/test/release$ ../../cmake --build .
/home/pavels/cmake/cmake-3.14.3-Linux-x86_64/bin/cmake -S/home/pavels/dev/cpp/test -B/home/pavels/dev/cpp/test/release --check-build-system CMakeFiles/Makefile.cmak                                           e 0
/home/pavels/cmake/cmake-3.14.3-Linux-x86_64/bin/cmake -E cmake_progress_start /home/pavels/dev/cpp/test/release/CMakeFiles /home/pavels/dev/cpp/test/release/CMakeF                                           iles/progress.marks
/usr/bin/make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/pavels/dev/cpp/test/release'
/usr/bin/make -f src/CMakeFiles/test.dir/build.make src/CMakeFiles/test.dir/depend
make[2]: Entering directory '/home/pavels/dev/cpp/test/release'
cd /home/pavels/dev/cpp/test/release && /home/pavels/cmake/cmake-3.14.3-Linux-x86_64/bin/cmake -E cmake_depends "Unix Makefiles" /home/pavels/dev/cpp/test /home/pav                                           els/dev/cpp/test/src /home/pavels/dev/cpp/test/release /home/pavels/dev/cpp/test/release/src /home/pavels/dev/cpp/test/release/src/CMakeFiles/test.dir/DependInfo.cm                                           ake --color=
Scanning dependencies of target test
make[2]: Leaving directory '/home/pavels/dev/cpp/test/release'
/usr/bin/make -f src/CMakeFiles/test.dir/build.make src/CMakeFiles/test.dir/build
make[2]: Entering directory '/home/pavels/dev/cpp/test/release'
[ 50%] Building CXX object src/CMakeFiles/test.dir/test.cpp.o
cd /home/pavels/dev/cpp/test/release/src && /usr/bin/c++   -I/home/pavels/dev/cpp/test/src  -std=gnu++1z -o CMakeFiles/test.dir/test.cpp.o -c /home/pavels/dev/cpp/t                                           est/src/test.cpp
[100%] Linking CXX executable test
cd /home/pavels/dev/cpp/test/release/src && /home/pavels/cmake/cmake-3.14.3-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
/usr/bin/c++    -rdynamic CMakeFiles/test.dir/test.cpp.o  -o test -llibpqxx
/usr/bin/ld: cannot find -llibpqxx
collect2: error: ld returned 1 exit status
src/CMakeFiles/test.dir/build.make:86: recipe for target 'src/test' failed
make[2]: *** [src/test] Error 1
make[2]: Leaving directory '/home/pavels/dev/cpp/test/release'
CMakeFiles/Makefile2:93: recipe for target 'src/CMakeFiles/test.dir/all' failed
make[1]: *** [src/CMakeFiles/test.dir/all] Error 2
make[1]: Leaving directory '/home/pavels/dev/cpp/test/release'
Makefile:86: recipe for target 'all' failed
make: *** [all] Error 2

./CMakeLists.txt

cmake_minimum_required(VERSION 3.12)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)

############ Project name and version
set (TEST_MAJOR_VERSION 1)
set (TEST_MINOR_VERSION 0)
set (TEST_PATCH_VERSION 0)
set (TEST_VERSION ${TEST_MAJOR_VERSION}.${TEST_MINOR_VERSION}.${TEST_PATCH_VERSION})

# Include our cmake macros
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
message (STATUS "Current source dir " ${CMAKE_CURRENT_SOURCE_DIR})
include (CMakeHelpers)

add_subdirectory (src)

src/CMakeLists.txt

init_target (test)
message (STATUS "set project " ${TARGET_NAME})
project (${TARGET_NAME} VERSION ${TEST_VERSION})

file (GLOB SOURCE_FILES
        *.cpp
        )
file (GLOB HEADER_FILES
        *.h
        )

find_package(libpqxx)

add_executable(${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries(test PRIVATE libpqxx)

Why package not found? How to link it well?

gnaggnoyil commented 5 years ago

Same issue here. The find package configuratuion file of libpqxx seems not to be installed by vcpkg while other libraries like protobuf does not have such issue.

flj commented 5 years ago

I have the same issue [though on alpine]

LilyWangL commented 4 years ago

Hi @pahan76, you should use find_library to find libpqxx. This is my CMakeLists.txt:

cmake_minimum_required (VERSION 3.9)

project (testpqxx C)

add_executable(testpqxx main.c)

find_path(LIBPQXX_INCLUDE_DIR pqxx)
find_library(LIBPQXX_LIBRARY liblibpqxx_static.a)
include_directories(${LIBPQXX_INCLUDE_DIR})
target_link_libraries(testpqxx PUBLIC ${LIBPQXX_LIBRARY})
LilyWangL commented 4 years ago

Thanks for posting this issue. Please reopen this issue if it still be a problem for you.

gnaggnoyil commented 4 years ago

@LilyWangL I'm sorry, but I don't think it is a common practice to use find_path and find_library directly instead of using a find_package configuration file to find libpqxx, nor it follows upstream's intention. Please reopen this issue and keep it open until a find_package configuration file can be installed though VcPkg.