static linking library
От | Kun Lu |
---|---|
Тема | static linking library |
Дата | |
Msg-id | 200403231800.i2NI0AoO010971@smtp4.server.rpi.edu обсуждение исходный текст |
Список | 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 по дате отправления: