Received: from owl4.owl.co.uk (eagle.owl.co.uk [194.201.150.9]) by hub.org (8.9.3/8.9.3) with SMTP id HAA36206 for ; Thu, 17 Feb 2000 07:15:19 -0500 (EST) (envelope-from chrish@owl.co.uk) Received: from dylan (unverified [192.168.150.45]) by owl4.owl.co.uk (Rockliffe SMTPRA 3.4.2) with SMTP id for ; Thu, 17 Feb 2000 12:04:33 +0000 From: "Chris Holman" To: 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> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 X-MIMEOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Importance: Normal 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