pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Holman <chrish@owl.co.uk>
To: pgsql-interfaces@postgresql.org
Subject: link problems when inheriting from libpq++
Date: Thu, 17 Feb 2000 12:21:47 -0000
Message-ID: <000801bf7941$8f9a1c20$2d96a8c0@dylan.owl.co.uk> (raw)

I have recently used the libpq++.a library as it stands to carry out SELECT
and INSERT command with few problems.
Its a pleasure to use, my compliments to you all. However...

I would now like to inherit the PgCursor class into one of my own classes.
Seems easy enough, but I have come up against a problem with the linker.

If I try to compile the code below with a simple makefile, the linker
(collect2) complains it cannot find the constructor for PgCursor. This is
true if I try to inherit from any of the classes in the libpq++.a library.
The linker output is shown below.

What am I doing wrong? If I comment out the declaration of 'newPgCursor
causesLinkErrors', then the code builds and works perfectly!

Are there link options I need to consider if I want to inherit from the
library?
I have tried building my own libraries and inheriting from them, using a
similar make file, but they work fine.

This has kept me going round in circles for a good few days now.
I would REALLY appreciate some suggestions, I seem to be getting nowhere!

Regards,
Chris Holman

******************** CODE STARTS **************************
#include "libpq++.H"

class newPgCursor: public PgCursor{
public:
   newPgCursor():PgCursor("dbname=testing", "cdh2"){}
};

void main(void){
   /***********  why does next line cause problems during
link?*************/
   newPgCursor causesLinkErrors;
   PgCursor cdh("dbname=testing", "cdh1");

   if(cdh.ConnectionBad()){ cout << "bad connection" << endl; exit(1);}

   if (!cdh.ExecCommandOk("insert into person (e_firstname) values ('a
Name');")){ 
      cout << "couldnt insert persons name" << endl;
   }

   cout << "check the program ran" << endl;
} 
******************** CODE ENDS **************************

******************** MAKEFILE STARTS **************************
CCC=g++

GCCOPTIONS= -frtti -D_CPPRTTI 

PGSQLDIR= /usr/include/pgsql
PGDIR= $(PGSQLDIR)/libpq
PGPLUSDIR=$(PGSQLDIR)/libpq++
PGLIBDIR= /usr/lib

INCLUDEPATH=  -I$(PGDIR) -I$(PGPLUSDIR) -I$(PGSQLDIR)

COMPILEDIRECTIVE= $(GCCOPTIONS) $(DEBUGOPTIONS) $(INCLUDEPATH)

LINKDIRECTIVE= -L$(PGLIBDIR)

TEST_APP= test.exe
 
bitstest: test.o 
	$(CCC) -o $(TEST_APP) test.o $(LINKDIRECTIVE) -lpq++ -lpq
	chmod 777 $(TEST_APP)

clean:
	rm -f *.o

.SUFFIXES: .cpp .C .cc .cxx .o

%.o: %.cpp
	$(CCC) $(COMPILEDIRECTIVE) -c $< -o $@ 
******************** MAKEFILE ENDS **************************


******************** LINKER OUTPUT STARTS **************************
[chrish@pigpen testString]$ make
g++ -frtti -D_CPPRTTI -D_UNIT_TEST_OBJECT_   -I/usr/include/pgsql/libpq -I/usr/i
nclude/pgsql/libpq++ -I/usr/include/pgsql -c test.cpp -o test.o
g++ -o test.exe test.o -L/usr/lib -lpq++ -lpq
test.o: In function `newPgCursor type_info function':
test.o(.gnu.linkonce.t.__tf11newPgCursor+0xd): undefined reference to `PgCursor
type_info function'
test.o(.gnu.linkonce.t.__tf11newPgCursor+0x14): undefined reference to `PgCursor
 type_info node'
collect2: ld returned 1 exit status
make: *** [bitstest] Error 1
******************** LINKER OUTPUT ENDS **************************

Regards,
Chris Holman






view thread (3+ messages)  latest in thread

Message-ID: <000801bf7941$8f9a1c20$2d96a8c0@dylan.owl.co.uk>
Permalink:  ../000801bf7941$8f9a1c20$2d96a8c0@dylan.owl.co.uk/
Also on:    postgresql.org/message-id/000801bf7941$8f9a1c20$2d96a8c0@dylan.owl.co.uk

 · 

reply

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: chrish@owl.co.uk
  Subject: Re: link problems when inheriting from libpq++
  In-Reply-To: <000801bf7941$8f9a1c20$2d96a8c0@dylan.owl.co.uk>

* 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