Обсуждение: Bug #448: 7.1.3 interfaces build fail on solaris w. gcc
Bob Deblier (bob@virtualunlimited.com) reports a bug with a severity of 1 The lower the number the more severe it is. Short Description 7.1.3 interfaces build fail on solaris w. gcc Long Description I've been having problems with doing a dlopen() of libpsqlodbc since version 7.1; now that I wanted to trace the probem Ifind the following problem during the build: make[2]: Entering directory `/opt/gnutools/postgresql-7.1.3/src/interfaces/odbc' gcc -Wall -Wmissing-prototypes -Wmissing-declarations -fPIC -G -Wl,-soname,libpsqlodbc.so.0 -Wl,-Bsymbolic info.o bind.ocolumninfo.o connection.o convert.o drvconn.o environ.o execute.o lobj.o misc.o options.o pgtypes.o psqlodbc.o qresult.oresults.o socket.o parse.o statement.o gpps.o tuple.o tuplelist.o dlg_specific.o multibyte.o -lm -lm -lc -Wl,-rpath,/opt/pgsql/lib-o libpsqlodbc.so.0.26 /usr/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/crt1.o: In function `nope': /usr/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/crt1.o(.text+0x5c): undefined reference to `main' socket.o: In function `SOCK_connect_to': socket.o(.text+0x280): undefined reference to `inet_addr' socket.o(.text+0x2a0): undefined reference to `gethostbyname' socket.o(.text+0x354): undefined reference to `socket' socket.o(.text+0x3b8): undefined reference to `connect' socket.o: In function `SOCK_flush_output': socket.o(.text+0x92c): undefined reference to `send' socket.o: In function `SOCK_get_next_byte': socket.o(.text+0x9e0): undefined reference to `recv' socket.o: In function `SOCK_put_next_byte': socket.o(.text+0xb80): undefined reference to `send' This shouldn't be too hard to fix by adding the -lsocket and -lnsl libraries. Furthermore the dynamic linking of libraries is wrong. You use the -G option, which is appropriate for Sun's compilers, butnot for gcc. With gcc, you have to use the '-shared' option. Hence all shared libraries fail to build because with a missing 'main' symbol. When this happens, the make process just continues,instead of aborting with an error. Maybe you should switch to building with libtool? Anyway, I'd appreciate it if I could directions to fix these problems. Sample Code No file was uploaded with this report
> Bob Deblier (bob@virtualunlimited.com) reports a bug with a severity of 1
> This shouldn't be too hard to fix by adding the -lsocket and -lnsl libraries.
Done.
> Furthermore the dynamic linking of libraries is wrong. You use the -G
> option, which is appropriate for Sun's compilers, but not for gcc.
> With gcc, you have to use the '-shared' option.
GCC documents -G for shared libraries, and people have been using that for
years. But it's probably not worth figuring this out since -shared is
clearly preferred.
> Hence all shared libraries fail to build because with a missing 'main'
> symbol. When this happens, the make process just continues, instead of
> aborting with an error.
Hmm, that's an interesting effect.
> Maybe you should switch to building with libtool?
Nope. ;-)
> Anyway, I'd appreciate it if I could directions to fix these problems.
1. in src/interfaces/odbc/GNUmakefile, change
SHLIB_LINK = $(filter -lm, $(LIBS))
to
SHLIB_LINK = $(filter -lm -lnsl -lsocket, $(LIBS))
2. in src/Makefile.shlib, change
LINK.shared = $(COMPILER) -G
into
ifndef cplusplus
ifeq ($(GCC), yes)
LINK.shared = $(CC) -shared
else
LINK.shared = $(CC) -G
endif
else
ifeq ($(GXX), yes)
LINK.shared = $(CXX) -shared
else
LINK.shared = $(CXX) -G
endif
endif
(Or just change the -G if you don't care about generality.)
--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter