Thread: Problems linking to libpq

Problems linking to libpq

From
"Jim Morcombe"
Date:
have started at the beginning of the PostSQL Programmer's Guide and have typed in part of example 1.1 on page 23.
 
I have followed the instructions in section 1.12 for building the program.
 
The program compiles cleanly using the instructions in the manual :
    cc -I/usr/local/pgsql/include jim.c
 
I then compile it with the instruction
    cc -o jim jim.o -L/usr/local/pgsql/lib -lpq
 
However, I get the following errors:
 
Undefined symbol
PQfinish
PQsetdbLogin
pqstatus
fprint
PQerrorMessage
 
The manual says this occurs if I forgot the -lpq option, which I have not done.
 
I am using SCO Unix.
 
Can anyone help me?
 
Jim Morcoombe
 

Re: Problems linking to libpq

From
Andrew McMillan
Date:
On Tue, 2002-07-16 at 15:59, Jim Morcombe wrote:
> have started at the beginning of the PostSQL Programmer's Guide and have typed in part of example 1.1 on page 23.
>
> I have followed the instructions in section 1.12 for building the program.
>
> The program compiles cleanly using the instructions in the manual :
>     cc -I/usr/local/pgsql/include jim.c
>
> I then compile it with the instruction
>     cc -o jim jim.o -L/usr/local/pgsql/lib -lpq
>
> However, I get the following errors:
>
> Undefined symbol
> PQfinish
> PQsetdbLogin
> pqstatus
> fprint
> PQerrorMessage
>
> The manual says this occurs if I forgot the -lpq option, which I have not done.

You haven't forgotten the libraries, you have forgotten the includes -
you will need a -I/path/to/postgres/include on there as well, I believe.

Regards,
                    Andrew.
--
--------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201    MOB: +64(21)635-694    OFFICE: +64(4)499-2267
       Are you enrolled at http://schoolreunions.co.nz/ yet?


Re: Problems linking to libpq

From
"Jim Morcombe"
Date:
I included the path to the Include Directory in the first "cc" command which
produced the Object files,
so I don't think this is my problem.

Jim

----- Original Message -----
From: Andrew McMillan <andrew@catalyst.net.nz>
To: Jim Morcombe <robust@vianet.net.au>
Cc: pgsql novice <pgsql-novice@postgresql.org>
Sent: Wednesday, July 17, 2002 9:06 AM
Subject: Re: [NOVICE] Problems linking to libpq


> On Tue, 2002-07-16 at 15:59, Jim Morcombe wrote:
> > have started at the beginning of the PostSQL Programmer's Guide and have
typed in part of example 1.1 on page 23.
> >
> > I have followed the instructions in section 1.12 for building the
program.
> >
> > The program compiles cleanly using the instructions in the manual :
> >     cc -I/usr/local/pgsql/include jim.c
> >
> > I then compile it with the instruction
> >     cc -o jim jim.o -L/usr/local/pgsql/lib -lpq
> >
> > However, I get the following errors:
> >
> > Undefined symbol
> > PQfinish
> > PQsetdbLogin
> > pqstatus
> > fprint
> > PQerrorMessage
> >
> > The manual says this occurs if I forgot the -lpq option, which I have
not done.
>
> You haven't forgotten the libraries, you have forgotten the includes -
> you will need a -I/path/to/postgres/include on there as well, I believe.
>
> Regards,
> Andrew.
> --
> --------------------------------------------------------------------
> Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
> WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
> DDI: +64(4)916-7201    MOB: +64(21)635-694    OFFICE: +64(4)499-2267
>        Are you enrolled at http://schoolreunions.co.nz/ yet?
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org


Re: Problems linking to libpq

From
Rasputin
Date:
* Jim Morcombe <robust@vianet.net.au> [020717 07:02]:
> I included the path to the Include Directory in the first "cc" command which
> produced the Object files,
> so I don't think this is my problem.


Try

cc -I/usr/local/pgsql/include jim.c -L/usr/local/pgsql/lib -lpq -o jim

to confirm. If that still fails, what OS are you running on?
What compiler?

And I'd also check that libpq.so is actually in /usr/local/pgsql/lib...

> Jim
>
> ----- Original Message -----
> From: Andrew McMillan <andrew@catalyst.net.nz>
> To: Jim Morcombe <robust@vianet.net.au>
> Cc: pgsql novice <pgsql-novice@postgresql.org>
> Sent: Wednesday, July 17, 2002 9:06 AM
> Subject: Re: [NOVICE] Problems linking to libpq
>
>
> > On Tue, 2002-07-16 at 15:59, Jim Morcombe wrote:
> > > have started at the beginning of the PostSQL Programmer's Guide and have
> typed in part of example 1.1 on page 23.
> > >
> > > I have followed the instructions in section 1.12 for building the
> program.
> > >
> > > The program compiles cleanly using the instructions in the manual :
> > >     cc -I/usr/local/pgsql/include jim.c
> > >
> > > I then compile it with the instruction
> > >     cc -o jim jim.o -L/usr/local/pgsql/lib -lpq
> > >
> > > However, I get the following errors:
> > >
> > > Undefined symbol
> > > PQfinish
> > > PQsetdbLogin
> > > pqstatus
> > > fprint
> > > PQerrorMessage
> > >
> > > The manual says this occurs if I forgot the -lpq option, which I have
> not done.
> >
> > You haven't forgotten the libraries, you have forgotten the includes -
> > you will need a -I/path/to/postgres/include on there as well, I believe.
> >
> > Regards,
> > Andrew.
> > --
> > --------------------------------------------------------------------
> > Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
> > WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
> > DDI: +64(4)916-7201    MOB: +64(21)635-694    OFFICE: +64(4)499-2267
> >        Are you enrolled at http://schoolreunions.co.nz/ yet?
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--
Rasputin :: Jack of All Trades - Master of Nuns

Re: Problems linking to libpq

From
Jason Davis
Date:
>Try
>
>cc -I/usr/local/pgsql/include jim.c -L/usr/local/pgsql/lib -lpq -o jim
>
>to confirm. If that still fails, what OS are you running on?
>What compiler?
>
>And I'd also check that libpq.so is actually in /usr/local/pgsql/lib...

I've had similar troubles linking to libpq on FreeBSD of late, which were
solved by including the directory /usr/local/include as this is where the
libpq libs have ended up being installed to in recent Postgres versions.
Perhaps check this directory for the libs.

cheers
Jason


>> ----- Original Message -----
>> From: Andrew McMillan <andrew@catalyst.net.nz>
>> To: Jim Morcombe <robust@vianet.net.au>
>> Cc: pgsql novice <pgsql-novice@postgresql.org>
>> Sent: Wednesday, July 17, 2002 9:06 AM
>> Subject: Re: [NOVICE] Problems linking to libpq
>>
>>
>> > On Tue, 2002-07-16 at 15:59, Jim Morcombe wrote:
>> > > have started at the beginning of the PostSQL Programmer's Guide and
have
>> typed in part of example 1.1 on page 23.
>> > >
>> > > I have followed the instructions in section 1.12 for building the
>> program.
>> > >
>> > > The program compiles cleanly using the instructions in the manual :
>> > >     cc -I/usr/local/pgsql/include jim.c
>> > >
>> > > I then compile it with the instruction
>> > >     cc -o jim jim.o -L/usr/local/pgsql/lib -lpq
>> > >
>> > > However, I get the following errors:
>> > >
>> > > Undefined symbol
>> > > PQfinish
>> > > PQsetdbLogin
>> > > pqstatus
>> > > fprint
>> > > PQerrorMessage
>> > >
>> > > The manual says this occurs if I forgot the -lpq option, which I have
>> not done.
>> >
>> > You haven't forgotten the libraries, you have forgotten the includes -
>> > you will need a -I/path/to/postgres/include on there as well, I believe.
>> >
>> > Regards,
>> > Andrew.
>> > --
>> > --------------------------------------------------------------------
>> > Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
>> > WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
>> > DDI: +64(4)916-7201    MOB: +64(21)635-694    OFFICE: +64(4)499-2267
>> >        Are you enrolled at http://schoolreunions.co.nz/ yet?
>> >
>> >
>> > ---------------------------(end of broadcast)---------------------------
>> > TIP 6: Have you searched our list archives?
>> >
>> > http://archives.postgresql.org
>>
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>--
>Rasputin :: Jack of All Trades - Master of Nuns
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster
>


Re: Problems linking to libpq

From
"Jim Morcombe"
Date:
Thanks for the sugestion, but no luck!

I tried the single line command you sugested :
> cc -I/usr/local/pgsql/include jim.c -L/usr/local/pgsql/lib -lpq -o jim
However, I got the same result.

I checked the directory /usr/local/pgsql/lib and libpq.so was there.
However it was a Symbolic Link to libpq.so.2.2
I copied libpq.so.2.2 to libpq.so but it made no difference.

I am running SCO Unix Version 3.2 release 5.0.5

I am using the standard SCO Unix Compiler which is called "cc".

Jim



----- Original Message -----
From: Rasputin <rasputin@idoru.mine.nu>
To: Jim Morcombe <robust@vianet.net.au>
Cc: <pgsql-novice@postgresql.org>
Sent: Wednesday, July 17, 2002 5:15 PM
Subject: Re: [NOVICE] Problems linking to libpq


> * Jim Morcombe <robust@vianet.net.au> [020717 07:02]:
> > I included the path to the Include Directory in the first "cc" command
which
> > produced the Object files,
> > so I don't think this is my problem.
>
>
> Try
>
> cc -I/usr/local/pgsql/include jim.c -L/usr/local/pgsql/lib -lpq -o jim
>
> to confirm. If that still fails, what OS are you running on?
> What compiler?
>
> And I'd also check that libpq.so is actually in /usr/local/pgsql/lib...
>
> > Jim
> >
> > ----- Original Message -----
> > From: Andrew McMillan <andrew@catalyst.net.nz>
> > To: Jim Morcombe <robust@vianet.net.au>
> > Cc: pgsql novice <pgsql-novice@postgresql.org>
> > Sent: Wednesday, July 17, 2002 9:06 AM
> > Subject: Re: [NOVICE] Problems linking to libpq
> >
> >
> > > On Tue, 2002-07-16 at 15:59, Jim Morcombe wrote:
> > > > have started at the beginning of the PostSQL Programmer's Guide and
have
> > typed in part of example 1.1 on page 23.
> > > >
> > > > I have followed the instructions in section 1.12 for building the
> > program.
> > > >
> > > > The program compiles cleanly using the instructions in the manual :
> > > >     cc -I/usr/local/pgsql/include jim.c
> > > >
> > > > I then compile it with the instruction
> > > >     cc -o jim jim.o -L/usr/local/pgsql/lib -lpq
> > > >
> > > > However, I get the following errors:
> > > >
> > > > Undefined symbol
> > > > PQfinish
> > > > PQsetdbLogin
> > > > pqstatus
> > > > fprint
> > > > PQerrorMessage
> > > >
> > > > The manual says this occurs if I forgot the -lpq option, which I
have
> > not done.
> > >
> > > You haven't forgotten the libraries, you have forgotten the includes -
> > > you will need a -I/path/to/postgres/include on there as well, I
believe.
> > >
> > > Regards,
> > > Andrew.
> > > --
> > > --------------------------------------------------------------------
> > > Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
> > > WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
> > > DDI: +64(4)916-7201    MOB: +64(21)635-694    OFFICE: +64(4)499-2267
> > >        Are you enrolled at http://schoolreunions.co.nz/ yet?
> > >
> > >
> > > ---------------------------(end of
broadcast)---------------------------
> > > TIP 6: Have you searched our list archives?
> > >
> > > http://archives.postgresql.org
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
> --
> Rasputin :: Jack of All Trades - Master of Nuns


Re: Problems linking to libpq

From
"Jim Morcombe"
Date:
Again, thanks for the advice, but still no good!

I tried specifying the include directory on the link path, but the result
was the same.

The libpq.so file is in the right directory and seems to be found.  I get a
different error message when libpq.so can't be found, so it seems to be a
problem reading the required routines from libpq.so.

Is there any way of displaying the routines held in libpq.so
or
how do I recreate libpq.so from the source?

Jim


----- Original Message -----
From: Jason Davis <jdavis@tassie.net.au>
To: Rasputin <rasputin@idoru.mine.nu>
Cc: <pgsql-novice@postgresql.org>
Sent: Thursday, July 18, 2002 10:45 AM
Subject: Re: [NOVICE] Problems linking to libpq


> >Try
> >
> >cc -I/usr/local/pgsql/include jim.c -L/usr/local/pgsql/lib -lpq -o jim
> >
> >to confirm. If that still fails, what OS are you running on?
> >What compiler?
> >
> >And I'd also check that libpq.so is actually in /usr/local/pgsql/lib...
>
> I've had similar troubles linking to libpq on FreeBSD of late, which were
> solved by including the directory /usr/local/include as this is where the
> libpq libs have ended up being installed to in recent Postgres versions.
> Perhaps check this directory for the libs.
>
> cheers
> Jason
>
>
> >> ----- Original Message -----
> >> From: Andrew McMillan <andrew@catalyst.net.nz>
> >> To: Jim Morcombe <robust@vianet.net.au>
> >> Cc: pgsql novice <pgsql-novice@postgresql.org>
> >> Sent: Wednesday, July 17, 2002 9:06 AM
> >> Subject: Re: [NOVICE] Problems linking to libpq
> >>
> >>
> >> > On Tue, 2002-07-16 at 15:59, Jim Morcombe wrote:
> >> > > have started at the beginning of the PostSQL Programmer's Guide and
> have
> >> typed in part of example 1.1 on page 23.
> >> > >
> >> > > I have followed the instructions in section 1.12 for building the
> >> program.
> >> > >
> >> > > The program compiles cleanly using the instructions in the manual :
> >> > >     cc -I/usr/local/pgsql/include jim.c
> >> > >
> >> > > I then compile it with the instruction
> >> > >     cc -o jim jim.o -L/usr/local/pgsql/lib -lpq
> >> > >
> >> > > However, I get the following errors:
> >> > >
> >> > > Undefined symbol
> >> > > PQfinish
> >> > > PQsetdbLogin
> >> > > pqstatus
> >> > > fprint
> >> > > PQerrorMessage
> >> > >
> >> > > The manual says this occurs if I forgot the -lpq option, which I
have
> >> not done.
> >> >
> >> > You haven't forgotten the libraries, you have forgotten the
includes -
> >> > you will need a -I/path/to/postgres/include on there as well, I
believe.
> >> >
> >> > Regards,
> >> > Andrew.
> >> > --
> >> > --------------------------------------------------------------------
> >> > Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
> >> > WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
> >> > DDI: +64(4)916-7201    MOB: +64(21)635-694    OFFICE: +64(4)499-2267
> >> >        Are you enrolled at http://schoolreunions.co.nz/ yet?
> >> >
> >> >
> >> > ---------------------------(end of
broadcast)---------------------------
> >> > TIP 6: Have you searched our list archives?
> >> >
> >> > http://archives.postgresql.org
> >>
> >>
> >> ---------------------------(end of
broadcast)---------------------------
> >> TIP 1: subscribe and unsubscribe commands go to
majordomo@postgresql.org
> >
> >--
> >Rasputin :: Jack of All Trades - Master of Nuns
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 4: Don't 'kill -9' the postmaster
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)


Re: Problems linking to libpq

From
Rasputin
Date:
* Jim Morcombe <robust@vianet.net.au> [020718 03:40]:
> Thanks for the sugestion, but no luck!
>
> I tried the single line command you sugested :
> > cc -I/usr/local/pgsql/include jim.c -L/usr/local/pgsql/lib -lpq -o jim
> However, I got the same result.
>
> I checked the directory /usr/local/pgsql/lib and libpq.so was there.
> However it was a Symbolic Link to libpq.so.2.2
> I copied libpq.so.2.2 to libpq.so but it made no difference.

Eck. It's supposed to be a symlink!
Put that directory back to how it was, that isn't your problem.


> I am running SCO Unix Version 3.2 release 5.0.5
>
> I am using the standard SCO Unix Compiler which is called "cc".

Hmm, maybe that's related - on NetBSD for example, you'd need to
tell the linker where the shared libraries you use are, using something like

gcc -I/usr/X11R6/include -o bhole -L/usr/X11R6/lib -Wl,-R/usr/X11R6/lib bhole.o -lm -lglut .....

Have you done much development on this platform before?
If not, it might be worth asking on a SCO group/list if the compiler has any
quirks.


--
Rasputin :: Jack of All Trades - Master of Nuns