Thread: RE: [INTERFACES] PgConnection

RE: [INTERFACES] PgConnection

From
"Vasquez, Jason"
Date:
Thanks for your response.

I tried your suggestion, and thing seem to go a little bit better--I still
receive one error at compile time, though.  (quite frustrating :) )

Hee's the error I receive:
$> g++ -I/usr/local/pgsql/include mytest.cpp -L/usr/local/pgsql/lib -lpq++
-lpq
/usr/local/pgsql/lib/libpq.a(fe-auth.o): In function 'pg_password_sendauth':
fe-auth.o(.text+0.17): undefined reference to 'crypt'

I even tried making sure that crypt.h was in g++'s search path, but I still
got the same error....

Any ideas?

TIA
-Jason




-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thursday, October 22, 1998 9:58 AM
To: Vasquez, Jason
Cc: pgsql-interfaces@hub.org
Subject: Re: [INTERFACES] PgConnection


"Vasquez, Jason" <Jason.Vasquez@Connect.Xerox.com> writes:
> I've read the documentation about using the C++ interface to Postgres, but
I
> seem to be havin trouble getting anything to compile.  Following the
example
> included with the distribution, I have done something similar to this:
> #include <iostream.h>
> #include <libpq++.h>
> void main() {
>   PgDatabase data ("foo");
> yadayadayada
> }
> Whenever I do this, I get a compile error stating that there is an
undefined
> reference to PgConnection.

Compile error, or link error?  I tried the same, and got complaints
about the linker not being able to find several PgConnection routines
until I added "-L/usr/local/pgsql/lib -lpq++ -lpq" to the command line:

$ g++ -I/usr/local/pgsql/include pgtest.cc
collect2: ld returned 1 exit status
/bin/ld: Unsatisfied symbols:
   PgConnection::PgConnection(void)(code)
   PgConnection::PgConnection(char const *)(code)
   PgConnection::~PgConnection(void)(code)
   PQfnumber (code)

$ g++ -I/usr/local/pgsql/include pgtest.cc -L/usr/local/pgsql/lib -lpq++
-lpq
[ no complaint ]

If you're using shared libraries there are also possibilities for
installation problems that prevent libpq++ from finding libpq at run
time, but evidently you're not getting that far yet :-(.

            regards, tom lane

Re: [INTERFACES] PgConnection

From
Tom Lane
Date:
"Vasquez, Jason" <Jason.Vasquez@Connect.Xerox.com> writes:
> Hee's the error I receive:
> $> g++ -I/usr/local/pgsql/include mytest.cpp -L/usr/local/pgsql/lib -lpq++ -lpq
> /usr/local/pgsql/lib/libpq.a(fe-auth.o): In function 'pg_password_sendauth':
> fe-auth.o(.text+0.17): undefined reference to 'crypt'

> I even tried making sure that crypt.h was in g++'s search path, but I still
> got the same error....

This is the same problem as before: you are seeing a link-time error not
a compile-time error.  You have to pay attention to whether the library
file can be found as well as whether the header file can be found.

On some machines the crypt functions are not in the standard C library
but in a separate file that you have to write "-lcrypt" to link in.
Perhaps yours is like that.

            regards, tom lane

Re: [INTERFACES] PgConnection

From
Gus Nwosu
Date:
At compile time include the line -L/usr/lib -lcrypt  while building the failed objects.

Rgds
Gus

At 09:56 AM 10/23/98 -0400, Tom Lane wrote:
>"Vasquez, Jason" <Jason.Vasquez@Connect.Xerox.com> writes:
>> Hee's the error I receive:
>> $> g++ -I/usr/local/pgsql/include mytest.cpp -L/usr/local/pgsql/lib -lpq++ -lpq
>> /usr/local/pgsql/lib/libpq.a(fe-auth.o): In function 'pg_password_sendauth':
>> fe-auth.o(.text+0.17): undefined reference to 'crypt'
>
>> I even tried making sure that crypt.h was in g++'s search path, but I still
>> got the same error....
>
>This is the same problem as before: you are seeing a link-time error not
>a compile-time error.  You have to pay attention to whether the library
>file can be found as well as whether the header file can be found.
>
>On some machines the crypt functions are not in the standard C library
>but in a separate file that you have to write "-lcrypt" to link in.
>Perhaps yours is like that.
>
>                       regards, tom lane
>
=============================================================
Gus Nwosu                                                                          Tel:  1-(713)350-4301
GeoRise Training Manager                                                     Fax: 1-(713)350-4103
5444 Westheimer Road
Houston. Tx 77056                                email: anwosu@houston.geoquest.slb.com
=============================================================