pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedlibpq (Postgres 7.2.1) + MacOS X 10.1.5 problem
2+ messages / 2 participants
[nested] [flat]
* libpq (Postgres 7.2.1) + MacOS X 10.1.5 problem
@ 2002-08-21 04:01 Stephen Lee <slee@acm.jhu.edu>
2002-08-21 04:31 ` Re: libpq (Postgres 7.2.1) + MacOS X 10.1.5 problem Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Lee @ 2002-08-21 04:01 UTC (permalink / raw)
To: pgsql-interfaces
Here's my simple program:
#include <stdio.h>
#include <libpq-fe.h>
int main() {
int i, j;
PGconn *dbconn;
PGresult *results;
dbconn = PQconnectdb(
"hostaddr=AN_IP_ADDR user=USERNAME dbname=SOMEDB"
);
results = PQexec( dbconn, "select * from account" );
for( i = 0; i < PQntuples( results ); i++ ) {
printf( "Row #%i\n", i );
for( j = 0; j < PQnfields( results ); j++ ) {
printf( " Field: %16s / Value: %s\n",
PQfname( results, j ), PQgetvalue( re
sults, i, j )
);
}
}
PQfinish( dbconn );
return( 0 );
}
I'm trying to compile a simple program using libpq and initially get
the following linker error:
-g -Wall -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpq test.c
-o test
/usr/bin/ld: table of contents for archive:
/usr/local/pgsql/lib/libpq.a is out of date; rerun ranlib(1) (can't
load from it)
make: *** [all] Error 1
After running ranlib on libpq.a, I get the following:
gcc -g -Wall -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpq
test.c -o test
/usr/bin/ld: Undefined symbols:
_PQconnectdb
_PQexec
_PQfinish
_PQfname
_PQgetvalue
_PQnfields
_PQntuples
make: *** [all] Error 1
Any ideas?
-Stephen
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: libpq (Postgres 7.2.1) + MacOS X 10.1.5 problem
2002-08-21 04:01 libpq (Postgres 7.2.1) + MacOS X 10.1.5 problem Stephen Lee <slee@acm.jhu.edu>
@ 2002-08-21 04:31 ` Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Momjian @ 2002-08-21 04:31 UTC (permalink / raw)
To: Stephen Lee <slee@acm.jhu.edu>; +Cc: pgsql-interfaces
Get that -lpq after the C file in the link line.
---------------------------------------------------------------------------
Stephen Lee wrote:
> Here's my simple program:
>
> #include <stdio.h>
> #include <libpq-fe.h>
>
> int main() {
> int i, j;
> PGconn *dbconn;
> PGresult *results;
>
> dbconn = PQconnectdb(
> "hostaddr=AN_IP_ADDR user=USERNAME dbname=SOMEDB"
> );
>
> results = PQexec( dbconn, "select * from account" );
>
> for( i = 0; i < PQntuples( results ); i++ ) {
> printf( "Row #%i\n", i );
>
> for( j = 0; j < PQnfields( results ); j++ ) {
> printf( " Field: %16s / Value: %s\n",
> PQfname( results, j ), PQgetvalue( re
> sults, i, j )
> );
> }
> }
>
> PQfinish( dbconn );
> return( 0 );
> }
>
> I'm trying to compile a simple program using libpq and initially get
> the following linker error:
>
> -g -Wall -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpq test.c
> -o test
> /usr/bin/ld: table of contents for archive:
> /usr/local/pgsql/lib/libpq.a is out of date; rerun ranlib(1) (can't
> load from it)
> make: *** [all] Error 1
>
> After running ranlib on libpq.a, I get the following:
>
> gcc -g -Wall -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpq
> test.c -o test
> /usr/bin/ld: Undefined symbols:
> _PQconnectdb
> _PQexec
> _PQfinish
> _PQfname
> _PQgetvalue
> _PQnfields
> _PQntuples
> make: *** [all] Error 1
>
> Any ideas?
>
> -Stephen
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-08-21 04:31 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-08-21 04:01 libpq (Postgres 7.2.1) + MacOS X 10.1.5 problem Stephen Lee <slee@acm.jhu.edu>
2002-08-21 04:31 ` Bruce Momjian <pgman@candle.pha.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox