Thread: PgConnection

PgConnection

From
"Vasquez, Jason"
Date:
I have just installed PostgreSQL, and the installation took place with no
problems/errors.

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.  Has anyone had a similar situation, or know how
to remedy this?

Thanks,
-Jason


Re: [INTERFACES] PgConnection

From
Joris Esch
Date:
On Wed, 21 Oct 1998, you wrote:
>I have just installed PostgreSQL, and the installation took place with no
>problems/errors.
>
>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.  Has anyone had a similar situation, or know how
>to remedy this?
>
>Thanks,
>-Jason

Hello:

look at the attached code. I hope it's usefull for you.

good luck
joris

--
joris esch, student in electrical engineering
        Power is knowledge.


Attachment

Re: [INTERFACES] PgConnection

From
Tom Lane
Date:
"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