我已经写了简单的程序。下面是一个代码:
#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退出状态
有人帮我吗?
迪菲克
发布于 2010-05-07 05:45:33
您可以尝试使用正斜杠而不是反斜杠。我对第一个正斜杠一无所知。它不是应该放在引号里吗?例如-I“/d:/程序文件/PostgreSQL/”
不管怎样,如果你用的是cygwin的gcc,你也可以试试
   -I"/cygdrive/d/Program Files/PostgreSQL"我也会对include (libpq-fe)做同样的事情--尽管这显然是有效的,但错误出在链接器中。
https://stackoverflow.com/questions/2783354
复制相似问题