2016-02-14 28 views
0

我試圖建立與PostgreSQL運行的SOCI庫。我按照這些步驟:如何使用PostgreSQL構建SOCI?

  • 在Ubutu安裝PostgreSQL 15.10
  • 下載SOCI源代碼
  • 提取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 

在安裝了"postgresql-devel.x86_64 : PostgreSQL development header files and libraries"的Linux系統,這個命令應該足夠了。

相關問題