问题描述
我在 Visual Studio 2019 中创建了 C++ 控制台应用程序。
然后我添加了 Additional Include Directory
;
C:\***\vcpkg-master\packages\libpq_x64-windows\bin
C:\***\vcpkg-master\packages\libpq_x64-windows\include
在那之后,我还添加了 #include "libpq-fe.h"
之类的 libpq 示例。
你可以在屏幕截图 Screen Shot is here 中看到我的代码,我得到 未解析的外部符号 PQconnectdb 在函数 main CLibpq 中引用
来源
#include <iostream>
#include "libpq-fe.h"
int main()
{
const char* conninfo;
PGconn* conn;
PGresult* res;
int nFields;
int i,j;
conninfo = "dbname = postgres;password = 123";
/* Make a connection to the database */
conn = PQconnectdb(conninfo);
if (PQstatus(conn) != CONNECTION_OK)
{
fprintf(stderr,"Connection to database failed: %s",PQerrorMessage(conn));
}
return 1;
}
https://www.postgresql.org/docs/8.1/libpq-build.html
https://www.postgresql.org/docs/8.1/libpq-example.html
https://www.postgresql.org/docs/8.1/client-interfaces.html#AEN24558
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)