Skip site navigation (1) Skip section navigation (2)

Difficulty getting started with Postgres C++ interface

From: "David Wright" <dwright(at)mergetel(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Difficulty getting started with Postgres C++ interface
Date: 2003-01-27 22:42:11
Message-ID: pan.2003.01.27.17.41.54.499.3486@mergetel.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
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>

Responses

pgsql-interfaces by date

Next:From: Gerhard HäringDate: 2003-01-28 09:00:06
Subject: Re: Python DB-API problem with PostgresSQL pgdb.
Previous:From: J GreenbaumDate: 2003-01-27 21:19:11
Subject: access field names w/ DBD

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group