After I've written some test programs for the socket functions accept(), ..., shutdown(), these programs get link errors on Solaris 10:
cc -O -g -o test-accept test-accept.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file accept test-accept.o ld: fatal: Symbol referencing errors. No output written to test-accept gmake[2]: *** [test-accept] Error 2 cc -O -g -o test-bind test-bind.o libtests.a ../gllib/libgnu.a libtests.a -lnsl Undefined first referenced symbol in file bind test-bind.o ld: fatal: Symbol referencing errors. No output written to test-bind gmake[2]: *** [test-bind] Error 2 cc -O -g -o test-connect test-connect.o libtests.a ../gllib/libgnu.a libtests.a -lnsl Undefined first referenced symbol in file connect test-connect.o ld: fatal: Symbol referencing errors. No output written to test-connect gmake[2]: *** [test-connect] Error 2 cc -O -g -o test-getpeername test-getpeername.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file getpeername test-getpeername.o ld: fatal: Symbol referencing errors. No output written to test-getpeername gmake[2]: *** [test-getpeername] Error 2 cc -O -g -o test-getsockname test-getsockname.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file getsockname test-getsockname.o ld: fatal: Symbol referencing errors. No output written to test-getsockname gmake[2]: *** [test-getsockname] Error 2 cc -O -g -o test-getsockopt test-getsockopt.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file getsockopt test-getsockopt.o ld: fatal: Symbol referencing errors. No output written to test-getsockopt gmake[2]: *** [test-getsockopt] Error 2 cc -O -g -o test-listen test-listen.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file listen test-listen.o ld: fatal: Symbol referencing errors. No output written to test-listen gmake[2]: *** [test-listen] Error 2 cc -O -g -o test-recv test-recv.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file recv test-recv.o ld: fatal: Symbol referencing errors. No output written to test-recv gmake[2]: *** [test-recv] Error 2 cc -O -g -o test-recvfrom test-recvfrom.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file recvfrom test-recvfrom.o ld: fatal: Symbol referencing errors. No output written to test-recvfrom gmake[2]: *** [test-recvfrom] Error 2 cc -O -g -o test-send test-send.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file send test-send.o ld: fatal: Symbol referencing errors. No output written to test-send gmake[2]: *** [test-send] Error 2 cc -O -g -o test-sendto test-sendto.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file sendto test-sendto.o inet_pton test-sendto.o ld: fatal: Symbol referencing errors. No output written to test-sendto gmake[2]: *** [test-sendto] Error 2 cc -O -g -o test-setsockopt test-setsockopt.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file setsockopt test-setsockopt.o ld: fatal: Symbol referencing errors. No output written to test-setsockopt gmake[2]: *** [test-setsockopt] Error 2 cc -O -g -o test-shutdown test-shutdown.o libtests.a ../gllib/libgnu.a libtests.a Undefined first referenced symbol in file shutdown test-shutdown.o ld: fatal: Symbol referencing errors. No output written to test-shutdown The fix is to link with $(LIBSOCKET), as determined by the 'socketlib' module. 2011-09-18 Bruno Haible <[email protected]> socket functions: Avoid link errors on Solaris. * modules/accept (Depends-on): Add socketlib. (Link): New section. * modules/bind (Depends-on): Add socketlib. (Link): New section. * modules/connect (Depends-on): Add socketlib. (Link): New section. * modules/getpeername (Depends-on): Add socketlib. (Link): New section. * modules/getsockname (Depends-on): Add socketlib. (Link): New section. * modules/getsockopt (Depends-on): Add socketlib. (Link): New section. * modules/listen (Depends-on): Add socketlib. (Link): New section. * modules/recv (Depends-on): Add socketlib. (Link): New section. * modules/recvfrom (Depends-on): Add socketlib. (Link): New section. * modules/send (Depends-on): Add socketlib. (Link): New section. * modules/sendto (Depends-on): Add socketlib. (Link): New section. * modules/setsockopt (Depends-on): Add socketlib. (Link): New section. * modules/shutdown (Depends-on): Add socketlib. (Link): New section. * modules/socket (Depends-on): Add socketlib. (Link): New section. --- modules/accept.orig Mon Sep 19 02:07:26 2011 +++ modules/accept Mon Sep 19 02:06:15 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -21,6 +22,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/bind.orig Mon Sep 19 02:07:26 2011 +++ modules/bind Mon Sep 19 02:06:15 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -21,6 +22,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/connect.orig Mon Sep 19 02:07:26 2011 +++ modules/connect Mon Sep 19 02:06:15 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -21,6 +22,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/getpeername.orig Mon Sep 19 02:07:26 2011 +++ modules/getpeername Mon Sep 19 02:06:15 2011 @@ -8,6 +8,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -22,6 +23,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/getsockname.orig Mon Sep 19 02:07:26 2011 +++ modules/getsockname Mon Sep 19 02:06:15 2011 @@ -8,6 +8,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -22,6 +23,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/getsockopt.orig Mon Sep 19 02:07:26 2011 +++ modules/getsockopt Mon Sep 19 02:06:15 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib sys_time [test "$ac_cv_header_winsock2_h" = yes] errno [test "$ac_cv_header_winsock2_h" = yes] @@ -22,6 +23,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/listen.orig Mon Sep 19 02:07:26 2011 +++ modules/listen Mon Sep 19 02:06:15 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -21,6 +22,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/recv.orig Mon Sep 19 02:07:26 2011 +++ modules/recv Mon Sep 19 02:06:15 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -21,6 +22,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/recvfrom.orig Mon Sep 19 02:07:26 2011 +++ modules/recvfrom Mon Sep 19 02:06:16 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] getpeername [test "$ac_cv_header_winsock2_h" = yes] @@ -22,6 +23,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/send.orig Mon Sep 19 02:07:26 2011 +++ modules/send Mon Sep 19 02:06:16 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -21,6 +22,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/sendto.orig Mon Sep 19 02:07:26 2011 +++ modules/sendto Mon Sep 19 02:06:16 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -21,6 +22,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/setsockopt.orig Mon Sep 19 02:07:26 2011 +++ modules/setsockopt Mon Sep 19 02:06:16 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib sys_time [test "$ac_cv_header_winsock2_h" = yes] errno [test "$ac_cv_header_winsock2_h" = yes] @@ -22,6 +23,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/shutdown.orig Mon Sep 19 02:07:26 2011 +++ modules/shutdown Mon Sep 19 02:06:16 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] configure.ac: @@ -21,6 +22,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ --- modules/socket.orig Mon Sep 19 02:19:05 2011 +++ modules/socket Mon Sep 19 02:17:06 2011 @@ -7,6 +7,7 @@ Depends-on: sys_socket +socketlib errno [test "$ac_cv_header_winsock2_h" = yes] sockets [test "$ac_cv_header_winsock2_h" = yes] @@ -31,6 +32,9 @@ Include: <sys/socket.h> +Link: +$(LIBSOCKET) + License: LGPLv2+ -- In memoriam Bernhard Bästlein <http://en.wikipedia.org/wiki/Bernhard_Bästlein>
