我写了简单的程序。 这是一个代码:
#include <iostream>
#include <stdio.h>
#include <D:\Program Files\PostgreSQL\8.4\include\libpq-fe.h>
#include <string>
using namespace std;
int main()
{
PGconn *conn;
PGresult *res;
int rec_count;
int row;
int col;
cout << "ble ble: " << 8 << endl;
conn = PQconnectdb("dbname=db_pm host=localhost user=postgres password=postgres");
if (PQstatus(conn) == CONNECTION_BAD) {
puts("We were unable to connect to the database");
exit(0);
}
}
我正在尝试与PostgreSQL连接。 我使用以下命令编译此代码:
gcc -I /“d:\ Program Files \ PostgreSQL \” - L /“d:\ Program Files \ PostgreSQL \ 8.4 \ lib \” - lpq -o firstcpp.o firstcpp.cpp
此命令来自以下网站: http://www.mkyong.com/database/how-to-building-postgresql-libpq-programs/
当我编译它时,我得到以下错误: / cygnus / cygwin-b20 / H-i586-cygwin32 / i586-cygwin32 / bin / ld:无法打开-lpq:没有这样的文件或目录 collect2:ld返回1退出状态
有人帮助我吗?
Difek
答案 0 :(得分:1)
您可以尝试使用正斜杠而不是反斜杠。我不知道第一个正斜杠。是不是意味着在报价内?例如-I“/ d:/ Program Files / PostgreSQL /”
无论如何,如果你使用cygwin的gcc,你也可以尝试
-I"/cygdrive/d/Program Files/PostgreSQL"
我会对include(libpq-fe)做同样的事情 - 虽然显然有效,但错误在链接器中。