gpt4 book ai didi

c++ - 如何使用 PostgreSQL 构建 SOCI?

转载 作者:行者123 更新时间:2023-11-29 12:36:42 27 4
gpt4 key购买 nike

我正在尝试构建 SOCI 库以与 PostgreSQL 一起运行。我遵循了以下步骤:

  • 在 Ubutu 15.10 中安装 PostgreSQL
  • 下载 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 警告和构建错误的原因可能是什么吗?

最佳答案

尝试使用稍微不同的选项调用 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

关于c++ - 如何使用 PostgreSQL 构建 SOCI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35392767/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com