首页 > 解决方案 > 为 postgresql 编译 libpqxx C++ 库时找不到 libpq-fe.h

问题描述

我正在尝试安装 libpqxx 库以使用 C++ 连接到 postgresDB,我正在使用 Msys 和 Mingw32。当我./configure在 msys 控制台上运行时,我在控制台上收到此消息(如下)。当我检查pg_config --includedir目录时,我可以看到头文件 libpq-fe.h 在那里,我在哪里做错了。我在一个windows平台上我已经安装了postgres v.10 libpqxx版本是4.0也是我设置的路径环境像这样导出PATH="$PATH:/c/Program Files/PostgreSQL/10/bin"

checking for pg_config... /c/Program Files/PostgreSQL/10/bin/pg_config
./configure: line 15928: /c/Program: No such file or directory
configure: using PostgreSQL headers at
./configure: line 15931: /c/Program: No such file or directory
configure: using PostgreSQL libraries at
checking for ANSI C header files... (cached) yes
checking ability to compile programs using the standard C library... yes
checking for library containing select... no
checking for main in -lws2_32... yes
checking /libpq-fe.h usability... no
checking /libpq-fe.h presence... no
checking for /libpq-fe.h... no
configure: error:
Can't find libpq-fe.h in .  Are you sure the libpq
    headers are installed correctly?  They should be in the directory returned by
    "pg_config --includedir".

标签: c++postgresqllibpqxx

解决方案


我发现问题在于环境 PATH 变量中的间距,因此我没有在 Program files 文件夹中安装 postgres,而是创建了另一个名称中没有空格的文件夹,所以我的导出是这样PATH="$PATH:/c/MyPostgreSQLFOLDER/PostgreSQL/10/bin"的,您可以随意命名文件夹不要在名称中包含任何空格。希望这可以帮助那里的任何人。


推荐阅读