09-23-05 10:55 PM
grid <prohit99@gmail.com> wrote:
# >>CC cl.cpp -lsocket
# >
# > Undefined first referenced
# > symbol in file
# > gethostbyname cl.o (symbol belongs to implicit
# > dependency /usr/lib/libnsl.so.1)
# >
# >
# > function socket() and connect() are fine,
# > but gethostbyname() is still not linked.
#
# If you look in the man pages of the socket() call(On Solaris,section3C
# ),it gives the following usage details :
# cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
#
# Also I suppose since its a Solaris box,the socket() and related
# functions are available as libraries (libsocket and libnsl)and not as
# system calls,though they may internally be calling the system calls
# specific to the platform.
# On systems like Linux,socket() and related functions are system calls in
# the kernel and hence doesn't need the libraries to be specified(the
# entries/stubs are present in the libc library for the system calls).
gethostbyname potentially does a DNS lookup. It can do its own
TCP or UDP socket code internally before returning. That's far
too much work to put into the kernel. On the unices I've used,
its in the libc equivalent; libc can include many things beyond
kernel calls.
Kernel calls like socket() or read() still often require a
small bit of user space code to convert the C (or Fortran or ...)
calling conventions to the particular register/stack/interrupt
code/etc used to transfer calls across the kernel-user interface.
These little bits of code are loaded from the library.
--
SM Ryan http://www.rawbw.com/~wyrmwif/
TEMPORARILY CLOSED
BE OPENED AFTER FIRST PERIOD
[ Post a follow-up to this message ]
|