0

I'm trying to include libpqxx to my project. For this I build it with configure script as it said here.
After install I have .a file in /user/local/lib and headers in /usr/local/include/pqxx
I have this in my CmakeLists.txt:

target_include_directories("${PROJECT_NAME}" PUBLIC /usr/local/include)
target_link_libraries("${PROJECT_NAME}" PRIVATE ${PROJECT_NAME} pqxx)

This is in my main.cpp: #include <pqxx/pqxx>

When I launch in the build folder

cmake ..
cmake --build ./

I get many errors like this:

/usr/bin/ld: /usr/local/lib/libpqxx.a(result.o): in function `pqxx::result::column_number(pqxx::zview) const':
/home/armhf/myuser/libpq/src/result.cxx:401: undefined reference to `PQfnumber'
/usr/bin/ld: /usr/local/lib/libpqxx.a(result.o): in function `pqxx::result::table_column(int) const':
/home/armhf/myuser/libpq/src/result.cxx:429: undefined reference to `PQftablecol'
/usr/bin/ld: /usr/local/lib/libpqxx.a(result.o): in function `pqxx::result::columns() const':
/home/armhf/myuser/libpq/src/result.cxx:485: undefined reference to `PQnfields'
/usr/bin/ld: /usr/local/lib/libpqxx.a(result.o): in function `pqxx::internal::clear_result(pg_result const*)':

I don't even have /home/armhf/myuser/libpq folder and cmake shows me errors in files there. I don't understand what is wrong.

Dmitry
  • 160
  • 9
  • 3
    "I don't even have /home/armhf/myuser/libpq folder and cmake shows me errors in files there" - You incorrectly understand the error message. The error is about **static library** `/usr/local/lib/libpqxx.a`, against which you are linking. Because a static library is an archive of the object files, then linker shows you the name of the object file - `result.o` - which refers to the undefined symbol. The source file `/home/armhf/myuser/libpq/src/result.cxx` is the one, from which that object file has been created on **other machine**, when the library was built. – Tsyvarev Oct 14 '22 at 08:06

0 Answers0