0

I have written a simple server program using socket functions. When compiled with g++, it gives undefined symbol error for send, __xnet_socket, listen, accept, __xnet_bind.

Why the symbols for socket and bind are different than others. Also, when the program is compiled using gcc, this 'xnet' difference does not happen. This linking error goes when linked with libsocket.so.

Actually, I am writing a shared library which overloads these socket API's and intercept them using dlsym(). On Solaris, when this library is compiled with gcc, these calls goes through the library, but when compiled with g++, socket() and bind() calls does not gets intercepted, but all other apis goes through the library.

Has libxnet.so to do something with this? Can dtrace be of some help?

aaa
  • 415
  • 6
  • 15
  • 1
    *When compiled with g++, it gives undefined symbol error for send, __xnet_socket, listen, accept, __xnet_bind.* That sounds like you're not linking with `-lxnet`. Post your link command[s]. – Andrew Henle Dec 07 '17 at 10:45

1 Answers1

0

You need to link with libsocket (via -lsocket) in order for the linker to pick up those functions. libxnet is a filter library in 11.3; the functions were moved from libxnet to libsocket, libnsl and libc.

I've found in the past when building OSS on Solaris that appending -lsocket -lnsl to LDLIBS generally gets me through configure and build stages with ease. The linker is smart enough to remove unnecessary references from the output.

James McPherson
  • 2,476
  • 1
  • 12
  • 16