Thread: Can't link to libpq
I have posted this on the Novice Mailing list without getting a resolution. Can anyone here help me?
I have started at the beginning of the PostSQL 7.2 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
On Fri, 2002-07-19 at 07:15, Jim Morcombe wrote: > 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 ... > The manual says this occurs if I forgot the -lpq option, which I have not done. Does libpq.so exist in /usr/local/pgsql/lib? It should be a symbolic link; does its target exist? -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight, UK http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Blessed is the man that trusteth in the LORD, and whose hope the LORD is." Jeremiah 17:7
Yes, libpq.so exists and is in /usr/local/pgsql/lib All of the permissions are okay. It was a symbolic link. Just to make sure, I renamed libpq2.2.so tp be libpq.so, but it made no difference. Jim ----- Original Message ----- From: Oliver Elphick <olly@lfix.co.uk> To: Jim Morcombe <jim@byronics.com.au> Cc: pgsql General <pgsql-general@postgresql.org> Sent: Friday, July 19, 2002 4:01 PM Subject: Re: [GENERAL] Can't link to libpq > On Fri, 2002-07-19 at 07:15, Jim Morcombe wrote: > > > 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 > ... > > The manual says this occurs if I forgot the -lpq option, which I have not done. > > Does libpq.so exist in /usr/local/pgsql/lib? It should be a symbolic > link; does its target exist? > > -- > Oliver Elphick Oliver.Elphick@lfix.co.uk > Isle of Wight, UK > http://www.lfix.co.uk/oliver > GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C > ======================================== > "Blessed is the man that trusteth in the LORD, and > whose hope the LORD is." Jeremiah 17:7
"Jim Morcombe" <jim@byronics.com.au> writes: > However, I get the following errors: > Undefined symbol > PQfinish > PQsetdbLogin > pqstatus > fprint > PQerrorMessage At least two of those are obviously your own typos (fprint presumably should be fprintf, and pqstatus should be PQstatus). The others look like they should have worked, but I'm kinda suspicious that there's another typo lurking somewhere. Since you did not get link errors for PQexec and several other library routines that are used in example 1-1, it seems clear that you are successfully linking to libpq.so. Why are these three names failing? I dunno, but I suspect typos ... regards, tom lane
Tom The problem is that I am not sucessfully linking to libpq.so. I have run out of ideas and neeed help. The "fprint" was a typo and is now fixed. I didn't "cut & paste" my error messages. I retyped my errror message and made a typo in "pqstatus", but the actual error message has "PQstatus". None of the functions in libpq.so are linking. I removed all of the code in example 1-1 except the parts to open and close the connection, so I didn't get a link error on PQexec because I had chopped it out to come up with a simpler example. If I type in the complete example, I get more link errors. Jim ----- Original Message ----- From: Tom Lane <tgl@sss.pgh.pa.us> To: Jim Morcombe <jim@byronics.com.au> Cc: pgsql General <pgsql-general@postgresql.org> Sent: Friday, July 19, 2002 9:16 PM Subject: Re: [GENERAL] Can't link to libpq > "Jim Morcombe" <jim@byronics.com.au> writes: > > However, I get the following errors: > > > Undefined symbol > > PQfinish > > PQsetdbLogin > > pqstatus > > fprint > > PQerrorMessage > > At least two of those are obviously your own typos (fprint presumably > should be fprintf, and pqstatus should be PQstatus). The others look > like they should have worked, but I'm kinda suspicious that there's > another typo lurking somewhere. Since you did not get link errors for > PQexec and several other library routines that are used in example 1-1, > it seems clear that you are successfully linking to libpq.so. Why are > these three names failing? I dunno, but I suspect typos ... > > regards, tom lane