pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedlink problems when inheriting from libpq++
3+ messages / 2 participants
[nested] [flat]
* link problems when inheriting from libpq++
@ 2000-02-17 12:21 Chris Holman <chrish@owl.co.uk>
2000-02-17 17:31 ` Re: [INTERFACES] link problems when inheriting from libpq++ Guido Goldstein <guido@gold.siebend.net>
0 siblings, 1 reply; 3+ messages in thread
From: Chris Holman @ 2000-02-17 12:21 UTC (permalink / raw)
To: 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++ -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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [INTERFACES] link problems when inheriting from libpq++
2000-02-17 12:21 link problems when inheriting from libpq++ Chris Holman <chrish@owl.co.uk>
@ 2000-02-17 17:31 ` Guido Goldstein <guido@gold.siebend.net>
2000-02-18 11:35 ` RE: [INTERFACES] link problems when inheriting from libpq++ Chris Holman <chrish@owl.co.uk>
0 siblings, 1 reply; 3+ messages in thread
From: Guido Goldstein @ 2000-02-17 17:31 UTC (permalink / raw)
To: pgsql-interfaces; +Cc: Chris Holman <chrish@owl.co.uk>
Hi!
On Thu, 17 Feb 2000 12:21:47 -0000
"Chris Holman" <chrish@owl.co.uk> wrote:
[...]
> void main(void){
> /*********** why does next line cause problems during
> link?*************/
> newPgCursor causesLinkErrors;
> PgCursor cdh("dbname=testing", "cdh1");
[...]
> CCC=g++
>
> GCCOPTIONS= -frtti -D_CPPRTTI
^^^^^^^
Viewpoint 1
[...]
> ******************** 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'
Read the error message!
You're compiling your program with RTTI (runtime-type-information)
enabled (see Viepoint 1). Before you can use other C++-Libs you have
to make sure that these libs also include the RTTI code.
HIH
Guido
--
The biggest improvement in performance is the non-working-to-working
transition. -- John Ousterhout
^ permalink raw reply [nested|flat] 3+ messages in thread
* RE: [INTERFACES] link problems when inheriting from libpq++
2000-02-17 12:21 link problems when inheriting from libpq++ Chris Holman <chrish@owl.co.uk>
2000-02-17 17:31 ` Re: [INTERFACES] link problems when inheriting from libpq++ Guido Goldstein <guido@gold.siebend.net>
@ 2000-02-18 11:35 ` Chris Holman <chrish@owl.co.uk>
0 siblings, 0 replies; 3+ messages in thread
From: Chris Holman @ 2000-02-18 11:35 UTC (permalink / raw)
To: pgsql-interfaces
Thanks for the insightful observation Guido! VERY VERY much apreciated.
I will admit, I have not come across rtti until now. Hence why the error
meant nothing to me. Ahh well, back to the books.
The '-frtti' compile flag was copied from a makefile of another library I am
using.
The GCC manual has no reference to this flag! I can only assume that it is
the default?
If I replace it with '-fno-rtti' the example builds perfectly. I cant wait
to see how the other library reacts to this change.;-)
many thanks,
Chris Holman
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-02-18 11:35 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-02-17 12:21 link problems when inheriting from libpq++ Chris Holman <chrish@owl.co.uk>
2000-02-17 17:31 ` Guido Goldstein <guido@gold.siebend.net>
2000-02-18 11:35 ` Chris Holman <chrish@owl.co.uk>
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