libpq interface problem.

From: Shawn Stephens - Q Data KZN <ShawnS(at)ComparexAfrica(dot)co(dot)za>
To: "'pgsql-interfaces(at)postgresql(dot)org'" <pgsql-interfaces(at)postgresql(dot)org>
Subject: libpq interface problem.
Date: 2002-05-03 12:39:20
Message-ID: 5192C567A6FDD2119E1C0008C71E43D402A3A558@exchdbs01.pqafrica.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Hi All,

I have a version of SCO Openserver 5.0.5 installed.
I downloaded and installed the postgresql-7.2-VOLS.tar file from
www.caldera.com/skunkware (the openserver packages option)
I also had to download and install the zlib-1.1.4-VOLS.tar file as the
postgresql server would not initialise without the libz.so file.

Once all this was installed I created a database and everything seems to be
working fine.

I am now trying to write a 'C' interface against the database using libpq.
I have included the libpg-fe.h file in the 'C' code and have had some
troublesome results :
(I have called my program test.c).

If I type
cc -c -I/usr/local/pgsql/include test.c
the compiler creates a test.o file.
If I type
cc -o test test.o -L/usr/local/pgsql/lib -lpq
I get the following error messages :
undefined first referenced
symbol in file
PQconnectdb test.o
PQstatus test.o
PQerrorMessage test.o
PQexec test.o
PQgetvalue test.o
PQntuples test.o
PQclear test.o
PQfinish test.o
i386ld fatal: Symbol referencing errors. No output written to test

So, I tried to get clever and downloaded the gcc-2.95.2pl1-VOLS.tar binary
file and installed it.
Now if I type
/usr/local/bin/gcc -c -I/usr/local/pgsql/include test.c
the GNU compiler creates a test.o file.
If I type
/usr/local/bin/gcc -o test test.o -L/usr/local/pgsql/lib -lpq
I get the following error messages :
Undefined first referenced
symbol in file
htonl /usr/local/pgsql/lib/libpq.so
recv /usr/local/pgsql/lib/libpq.so
htons /usr/local/pgsql/lib/libpq.so
socket /usr/local/pgsql/lib/libpq.so
send /usr/local/pgsql/lib/libpq.so
connect /usr/local/pgsql/lib/libpq.so
gethostbyname /usr/local/pgsql/lib/libpq.so
setsockopt /usr/local/pgsql/lib/libpq.so
getsockname /usr/local/pgsql/lib/libpq.so
ntohl /usr/local/pgsql/lib/libpq.so
ntohs /usr/local/pgsql/lib/libpq.so
getsockopt /usr/local/pgsql/lib/libpq.so
inet_aton /usr/local/pgsql/lib/libpq.so
test: fatal error: Symbol referencing errors. No output written to test
collect2: ld returned 1 exit status

If anybody has any ideas as to how I can get around this problem (and
possibly explain what I am doing wrong) it would be much appreciated.

If I have not directed this question to the correct forum, could you please
let me know who to send it to ?
Kind Regards

Shawn Stephens
Oracle Database Administrator

For: Comparex Africa (Pty) Ltd
Company Registration Number: 1993/003683/07

Tel : + 27 (0) 31 560 6309
Fax : + 27 (0) 31 560 6399
<mailto:shawns(at)ComparexAfrica(dot)co(dot)za>

NOTICE: This message and any attachments are confidential and intended
solely for the addressee. If you have received this message in error, please
notify Shawn Stephens at Comparex Africa (Pty) Ltd immediately, telephone
number +27 (0) 31 560 6309. Any unauthorised use, alteration or
dissemination is prohibited. Comparex Africa (Pty) Ltd accepts no liability
whatsoever for any loss whether it be direct, indirect or consequential,
arising from information made available and actions resulting there from.

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2002-05-03 14:44:34 Re: Schemas: status report, call for developers
Previous Message Tom Lane 2002-05-02 22:05:07 Re: Schemas: status report, call for developers