Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4D267475751 for ; Wed, 21 Aug 2002 00:31:07 -0400 (EDT) Received: from candle.pha.pa.us (216-55-132-35.dsl.san-diego.abac.net [216.55.132.35]) by postgresql.org (Postfix) with ESMTP id 3988F4754A3 for ; Wed, 21 Aug 2002 00:31:06 -0400 (EDT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id g7L4V1215205; Wed, 21 Aug 2002 00:31:01 -0400 (EDT) From: Bruce Momjian Message-Id: <200208210431.g7L4V1215205@candle.pha.pa.us> Subject: Re: libpq (Postgres 7.2.1) + MacOS X 10.1.5 problem In-Reply-To: <20020821040106.1E6E113EA7@centaur.acm.jhu.edu> To: Stephen Lee Date: Wed, 21 Aug 2002 00:31:01 -0400 (EDT) Cc: pgsql-interfaces@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/60 X-Sequence-Number: 3022 Get that -lpq after the C file in the link line. --------------------------------------------------------------------------- Stephen Lee wrote: > Here's my simple program: > > #include > #include > > 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