From: David Wright <dwright@mergetel.com>
To: pgsql-interfaces@postgresql.org
Subject: Difficulty getting started with Postgres C++ interface
Date: Mon, 27 Jan 2003 17:42:11 -0500
Message-ID: <pan.2003.01.27.17.41.54.499.3486@mergetel.com> (raw)
Hi there,
I have been successfully using the perl DBI interface for some time and
have just begun a new project which needs to be written in C++. My
problem is that I am unable to compile even a simple C++ program without
error.
I am running a Mandrake 8.1 distribution of Linux, Postgres version 7.1.2
(with the libpq++ stuff that came with it) and trying to compile with
g++.
my program is:
#include <iostream.h>
#include "libpq++.h"
int main()
{
// Open the connection to the database and make sure it is OK
const char* dbName="dbname=dwright";
PgDatabase data("dbName");
/* if ( data.ConnectionBad() ) {
cout << "Connection was unsuccessful..." << endl;
cout << "Error message returned: " << data.ErrorMessage() << endl;
return 1;
}
else
cout << "Connection successful... Enter queries below:" << endl;
// Interactively obtain and execute queries
ExecStatusType status;
string buf;
int done = 0;
while (!done)
{
cout << "> ";
cout.flush();
getline(cin, buf);
if ( buf != "" )
if ( (status = data.Exec( buf.c_str() ))
== PGRES_TUPLES_OK )
data.DisplayTuples();
else
cout << "No tuples returned..." << endl
<< "status = " << status << endl
<< "Error returned: "
<< data.ErrorMessage() << endl;
else
done = 1;
} */
return 0;
} // End main()
Note that I have commented out everything except the connect!!
my command line is:
g++ -I/usr/include/pgsql myc.cpp -o myc
and the error messages are:
/home/dwright/tmp/ccx7SvXE.o: In function `PgDatabase::PgDatabase(char const *)':
/home/dwright/tmp/ccx7SvXE.o(.PgDatabase::gnu.linkonce.t.(char const *)+0x13): undefined reference to `PgConnection::PgConnection(char const *)'
/home/dwright/tmp/ccx7SvXE.o: In function `PgDatabase::~PgDatabase(void)':
/home/dwright/tmp/ccx7SvXE.o(.gnu.linkonce.t._._10PgDatabase+0x1d): undefined reference to `PgConnection::~PgConnection(void)'
/home/dwright/tmp/ccx7SvXE.o: In function `PgDatabase type_info function':
/home/dwright/tmp/ccx7SvXE.o(.gnu.linkonce.t.__tf10PgDatabase+0x10): undefined reference to `PgConnection type_info function'
/home/dwright/tmp/ccx7SvXE.o(.gnu.linkonce.t.__tf10PgDatabase+0x18): undefined reference to `PgConnection type_info node'
collect2: ld returned 1 exit status
Any assistance will be greatly appreciated.
Regards,
David
--
David Wright
912 - 614 Lake Street
St. Catharines, ON L2N 6P6
Web Site: <http://www.mergetel.com/~dwright;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: dwright@mergetel.com
Subject: Re: Difficulty getting started with Postgres C++ interface
In-Reply-To: <pan.2003.01.27.17.41.54.499.3486@mergetel.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox