2016-02-14 2 views
0

Я пытаюсь построить библиотеку SOCI для работы с PostgreSQL. Я последовал за следующие действия:Как построить SOCI с PostgreSQL?

  • Установка PostgreSQL в Ubutu 15,10
  • Скачать SOCI исходный код
  • код Extract SOCI

я выполнить следующие команды:

mkdir build 
cd build 
cmake -G "Unix Makefiles" -DWITH_BOOST=OFF -DWITH_POSTGRESQL=ON -DPOSTGRESQL_INCLUDE_DIR=/usr/local/pgsql/include -DPOSTGRESQL_LIBRARIES=/usr/local/pgsql/lib ../soci 

В этот момент, CMake дал следующие предупреждения:

WARNING: Target "soci_postgresql" requests linking to directory "/usr/local/pgsql/lib". Targets may link only to libraries. CMake is dropping the item. 
WARNING: Target "soci_postgresql_static" requests linking to directory "/usr/local/pgsql/lib". Targets may link only to libraries. CMake is dropping the item. 
WARNING: Target "soci_postgresql_test" requests linking to directory "/usr/local/pgsql/lib". Targets may link only to libraries. CMake is dropping the item. 
WARNING: Target "soci_postgresql_test" requests linking to directory "/usr/local/pgsql/lib". Targets may link only to libraries. CMake is dropping the item. 
WARNING: Target "soci_postgresql_test_static" requests linking to directory "/usr/local/pgsql/lib". Targets may link only to libraries. CMake is dropping the item. 
WARNING: Target "soci_postgresql_test_static" requests linking to directory "/usr/local/pgsql/lib". Targets may link only to libraries. CMake is dropping the item. 

Упорно со сборкой, я побежал make, который выдает следующее сообщение об ошибке:

[ 98%] Building CXX object tests/postgresql/CMakeFiles/soci_postgresql_test.dir/test-postgresql.cpp.o 
Linking CXX executable ../../bin/soci_postgresql_test 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQresultStatus' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQgetvalue' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQclear' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQserverVersion' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQresultErrorMessage' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQexec' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `lo_lseek' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQfsize' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQgetisnull' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQerrorMessage' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `lo_open' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQexecPrepared' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQftype' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `lo_close' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQexecParams' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQfname' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQconnectdb' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQstatus' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQntuples' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQresultErrorField' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQfformat' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `lo_read' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQfinish' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQprepare' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `lo_write' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQcmdTuples' 
../../lib/libsoci_postgresql.so.4.0.0: undefined reference to `PQnfields' 
collect2: error: ld returned 1 exit status 
tests/postgresql/CMakeFiles/soci_postgresql_test.dir/build.make:89: recipe for target 'bin/soci_postgresql_test' failed 
make[2]: *** [bin/soci_postgresql_test] Error 1 
CMakeFiles/Makefile2:609: recipe for target 'tests/postgresql/CMakeFiles/soci_postgresql_test.dir/all' failed 
make[1]: *** [tests/postgresql/CMakeFiles/soci_postgresql_test.dir/all] Error 2 
Makefile:126: recipe for target 'all' failed 
make: *** [all] Error 2 

Любая идея, что причиной предупреждений CMake и построить ошибка может быть?

ответ

1

Попытка вызвать CMake с несколько различных вариантов

cmake -G "Unix Makefiles" -DWITH_BOOST=OFF -DWITH_POSTGRESQL=ON \ 
    -DPOSTGRESQL_INCLUDE_DIR:STRING="/usr/local/pgsql/include" \ 
    -DPOSTGRESQL_LIBRARIES:STRING="/usr/local/pgsql/lib" ../soci 
1

я получил правильный ответ от GitHub, here is link. Следующий ответ в основном взят оттуда, но здесь повторяется для удобства (с очисткой и очисткой):

-DPOSTGRESQL_LIBRARIES=/usr/local/psql/lib следует указывать на библиотеки, а не на каталоги.

Это то, что следующее предупреждение уже подчеркивает:

WARNING: Target "soci_postgresql" requests linking to directory "/usr/local/postgresql/lib"

Попробуйте следующую команду вместо (возможно, вам нужно удалить ваш CMakeCache.txt из каталога сборки первых, а):

cmake -G "Unix Makefiles" -DWITH_BOOST=OFF -DWITH_POSTGRESQL=ON ../soci 

On Linux, где установлен "postgresql-devel.x86_64 : PostgreSQL development header files and libraries", этой команды должно быть достаточно.