Thread: RE: [INTERFACES] Linking problems

RE: [INTERFACES] Linking problems

From
"Ansley, Michael"
Date:
You need to link to libpq as well (-lpq), so this line:
gcc  -o testsql testsql.o -lm -lstdc++ -lpq++

should look like this:
gcc  -o testsql testsql.o -lm -lstdc++ -lpq++ -lpq

Is this on the FAQ somewhere, because I've seen a couple of people asking
about this?


MikeA


>> -----Original Message-----
>> From: blackw@sfu.ca [mailto:blackw@sfu.ca]
>> Sent: Thursday, January 20, 2000 10:14 PM
>> To: pgsql-interfaces@postgreSQL.org
>> Subject: [INTERFACES] Linking problems
>> 
>> 
>> Hi,
>> 
>> I seem to have a problem with my libpq++ library.  I wrote a 
>> QnD test program that simply connects and disconnects from 
>> Postgres.  When I compile it, I get the following error messages:
>> 
>> --------------------
>> gcc  -o testsql testsql.o -lm -lstdc++ -lpq++
>> /usr/lib/libpq++.so: undefined reference to 
>> `clone__Q2t12basic_string3ZcZt18stri
>> ng_char_traits1ZcZt24__default_alloc_template2b1i03Rep'
>> /usr/lib/libpq++.so: undefined reference to 
>> `__dl__Q2t12basic_string3ZcZt18strin
>> g_char_traits1ZcZt24__default_alloc_template2b1i03RepPv'
>> /usr/lib/libpq++.so: undefined reference to `__eh_pc'
>> collect2: ld returned 1 exit status
>> make: *** [testsql] Error 1
>> --------------------
>> 
>> Here's the environment:
>> RH 6.1 (i386) (upgraded from 5.2)
>> egcs 1.1.2-24
>> libstdc++-2.9.0-24
>> postgresql-6.5.3-1.i386.rpm
>> 
>> I am guessing that there may be some library mix-up going on 
>> here, or I'm omitting a required library.
>> 
>> Alternatively, should I be using the postgresql-6.5.2 
>> release that comes with RH6.1?  (I had installed 6.5.3-1 
>> when I was running RH5.2.)
>> 
>> Any insight would be appreciated.  Thank-you in advance.
>> 
>> Cheers,
>> Richard
>> 
>> 
>> 
>> ************
>> 

************




Re: [INTERFACES] Linking problems

From
Richard
Date:
Thank-you, Mike.  Before posting, I did do some searches on various
pgsql mail lists and rummaged through the docs, but I didn't find any
mention of this.  Not to say it isn't there.  But if it is, it isn't
very obvious.  I'd have expected it to be in the "libpq C++ Binding"
section of the Programmer docs.  It isn't.

Last night in I downgraded to 6.5.2, and my test app linked fine WITHOUT
the -lpq option!  Is that link option requirement specific to 6.5.3?

Cheers,
Richard


"Ansley, Michael" wrote:
> 
> You need to link to libpq as well (-lpq), so this line:
> gcc  -o testsql testsql.o -lm -lstdc++ -lpq++
> 
> should look like this:
> gcc  -o testsql testsql.o -lm -lstdc++ -lpq++ -lpq
> 
> Is this on the FAQ somewhere, because I've seen a couple of people asking
> about this?
>


Re: [INTERFACES] Linking problems

From
Tom Lane
Date:
Richard <blackw@sfu.ca> writes:
> Last night in I downgraded to 6.5.2, and my test app linked fine WITHOUT
> the -lpq option!  Is that link option requirement specific to 6.5.3?

Hard to believe that 6.5.2 and 6.5.3 are any different here.  More
likely there is some configuration difference on your platform.
Shared libraries are handled weirdly on many Unixen --- the loader
may be configured to look automatically in some directories, for
example.  If you have "ldconfig" on your system, check its config file.
        regards, tom lane