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

static linking library

From: Kun Lu <luk(at)rpi(dot)edu>
To: pgsql-novice(at)postgresql(dot)org
Subject: static linking library
Date: 2004-03-23 13:00:10
Message-ID: 200403231800.i2NI0AoO010971@smtp4.server.rpi.edu (view raw or flat)
Thread:
Lists: pgsql-novice
Hi,
Currently I have postgresql DB setup on a sun machine.
I can compile( gcc -I/usr/local/pgsql/include sql.c -lpq ) and run a
testing query program on the same machine(which works fine), 
but when I try to run the same program in different machine(without the
postgresql library) on the network connecting to the same DB, it failed. 
So I tried to static link the library by doing the following steps(info
acquired from searching through the archives), but still have no success.
Anyone know where I am doing wrong? Thanks in advance.

gcc -I/usr/local/pgsql/include sql.c /usr/local/pgsql/lib/libpq.a

Undefined			first referenced
 symbol 			    in file
socket				   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
recv				    /usr/local/pgsql/lib/libpq.a(fe-misc.o)

gethostbyname			   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
send				   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
setsockopt			   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
inet_aton			   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
getsockopt			   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
getsockname			   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
connect 			   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

gcc -I/usr/local/pgsql/include sql.c /usr/local/pgsql/lib/libpq.a -lsocket
-lnsl

Undefined			first referenced
 symbol 			    in file
inet_aton			   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

gcc -I/usr/local/pgsql/include -static sql.c -lpq -lsocket -lnsl
Undefined			first referenced
 symbol 			    in file
dlclose 			    /usr/lib/libnsl.a(netdir.o)
inet_aton			   
/usr/local/pgsql/lib/libpq.a(fe-connect.o)
dlsym				    /usr/lib/libnsl.a(netdir.o)
dlopen				    /usr/lib/libnsl.a(netdir.o)
dlerror 			    /usr/lib/libnsl.a(netdir.o)
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

The headers I included in the sql.c are
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <libpq-fe.h>

Kun Lu


pgsql-novice by date

Next:From: Richard HaywardDate: 2004-03-23 20:54:00
Subject: Equivalent of mssql profiler?
Previous:From: Mokos P├ęterDate: 2004-03-23 12:05:34
Subject: Object Oriented features in PostgreSQL

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