Skip site navigation (1) Skip section navigation (2)

libpq (Postgres 7.2.1) + MacOS X 10.1.5 problem

From: Stephen Lee <slee(at)acm(dot)jhu(dot)edu>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: libpq (Postgres 7.2.1) + MacOS X 10.1.5 problem
Date: 2002-08-21 04:01:01
Message-ID: 20020821040106.1E6E113EA7@centaur.acm.jhu.edu (view raw or flat)
Thread:
Lists: 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

Responses

pgsql-interfaces by date

Next:From: Bruce MomjianDate: 2002-08-21 04:31:01
Subject: Re: libpq (Postgres 7.2.1) + MacOS X 10.1.5 problem
Previous:From: Frédéric BoucherDate: 2002-08-19 19:56:12
Subject: FreeBSD -pthread -lpq problem...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group