views:

22

answers:

1

Hi

I've written simple program. Here a code:

#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);
         }
}

I'm trying to connect with PostgreSQL. I compile this code with following command:

gcc -I/"d:\Program Files\PostgreSQL\" -L/"d:\Program Files\PostgreSQL\8.4\lib\" -lpq -o firstcpp.o firstcpp.cpp

This command is from following site: http://www.mkyong.com/database/how-to-building-postgresql-libpq-programs/

And when I compile it I get following error: /cygnus/cygwin-b20/H-i586-cygwin32/i586-cygwin32/bin/ld: cannot open -lpq: No such file or directory collect2: ld returned 1 exit status

Does anyone help me?

Difek

A: 

You can try using forward slashes instead of backward slashes. And I have no idea about the first forward slash. Isn't it meant to be inside the quotes ? Eg -I"/d:/Program Files/PostgreSQL/"

Anyway, if you are using the gcc from cygwin, you could also try

   -I"/cygdrive/d/Program Files/PostgreSQL"

And I'd do the same with that include (libpq-fe) - though apparently that is working, the error is in the linker.

leonbloy