link problems when inheriting from libpq++
От | Chris Holman |
---|---|
Тема | link problems when inheriting from libpq++ |
Дата | |
Msg-id | 000801bf7941$8f9a1c20$2d96a8c0@dylan.owl.co.uk обсуждение исходный текст |
Список | pgsql-interfaces |
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++ -lpqchmod 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 `PgCursortype_info node' collect2: ld returned 1 exit status make: *** [bitstest] Error 1 ******************** LINKER OUTPUT ENDS ************************** Regards, Chris Holman
В списке pgsql-interfaces по дате отправления: