Problem with libpq++ - Mailing list pgsql-interfaces
From | Tim Boring |
---|---|
Subject | Problem with libpq++ |
Date | |
Msg-id | 1007956603.13686.9.camel@tim Whole thread Raw |
Responses |
Re: Problem with libpq++
|
List | pgsql-interfaces |
I'm trying to compile the example program on p194 of PostgreSQL: Introduction and concepts, but the compiler (g++ v2.95.3) is complaining about an undefined reference to PgConnection::ConnectionBad() and other calls to class member functions. I've included the command I'm using to compile the source, the error message, and the source below. Any help in pointing out where the mistake is is greatly appreciated. Tim Here's the command line I'm using for compilation: g++ -I/usr/local/pgsql/include postgre.cpp -o postgre -L/usr/local/pgsql/lib -lpq++ But that fails with the following error: /tmp/ccErizeU.o: In function `main': 2 /tmp/ccErizeU.o(.text+0x2f): undefined reference to `PgConnection::Conne ctionBad()' 3 /tmp/ccErizeU.o(.text+0x50): undefined reference to `PgConnection::Error Message()' 4 /tmp/ccErizeU.o(.text+0x107): undefined reference to `PgConnection::Exec TuplesOk(char const*)' 5 /tmp/ccErizeU.o(.text+0x15b): undefined reference to `PgDatabase::Tuples ()' 6 /tmp/ccErizeU.o(.text+0x1a1): undefined reference to `PgDatabase::GetVal ue(int, int)' 7 /tmp/ccErizeU.o: In function `PgDatabase::PgDatabase(char const*)': 8 /tmp/ccErizeU.o(.gnu.linkonce.t._ZN10PgDatabaseC1EPKc+0x12): undefined r eference to `PgConnection::PgConnection(char const*)' 9 /tmp/ccErizeU.o: In function `PgDatabase::~PgDatabase()': 10 /tmp/ccErizeU.o(.gnu.linkonce.t._ZN10PgDatabaseD1Ev+0x1a): undefined ref erence to `PgConnection::~PgConnection()' 11 /tmp/ccErizeU.o: In function `PgDatabase::~PgDatabase()': 12 /tmp/ccErizeU.o(.gnu.linkonce.t._ZN10PgDatabaseD0Ev+0x1a): undefined ref erence to `PgConnection::~PgConnection()' 13 collect2: ld returned 1 exit status Here's the source I'm trying to compile: #include <iostream> 4 #include "libpq++.h" 5 6 int main() { 7 8 char state_code[3]; 9 char query_string[256]; 10 PgDatabase data("dbname=test"); 11 12 if ( data.ConnectionBad() ) { 13 cerr << "Connect to database failed." << endl 14 << "Error returned: " << data.ErrorMessage() 15 << endl; 16 exit(1); 17 } 18 19 cout << "Enter a state code: "; 20 cin.get(state_code, 3, '\n'); 21 22 sprintf( query_string, 23 "SELECT name \ 24 FROM statename \ 25 WHERE code= '%s'", state_code); 26 27 if ( !data.ExecTuplesOk(query_string) ) { 28 cerr << "SELECTquery failed." << endl; 29 exit(1); 30 } 31 32 for ( int i = 0; i < data.Tuples();i++ ) { 33 cout << data.GetValue(i,0) << endl; 34 } 35 36 return0; 37 38 }
pgsql-interfaces by date: