Click to See Complete Forum and Search --> : concerning "-lsocket"


juicychong
12-18-2003, 01:42 PM
i was trying to compile a socket while i tried to write a server according to the help of Beej's guide to Network Programming

the result came out as below:
--------
[juicy@juicy server]$ cc -o server server.c -lnsl -lsocket
/usr/bin/ld: cannot find -lsocket
collect2: ld returned 1 exit status
--------

I'm using Redhat Linux 9
and i'm just asking that
is there any problem with the "-lsocket"?
how may i change the command so that it works?

tecknophreak
12-18-2003, 01:49 PM
I can't find a libsocket* file on my machine, so I'm guessing that might be an older book? Anywho, I've been compiling socket programs for a while without ever including a socket-specific library in the compile. try:

cc -o server server.c -lnsl

bwkaz
12-18-2003, 08:00 PM
-lsocket is required on Solaris. It's not required on Linux, since Linux's C library has an implementation for it (Solaris' libc does not).

I'm not even entirely sure what's in -lnsl, but I'm fairly sure you don't need it for most socket stuff.

Stuka
12-19-2003, 10:38 AM
Found this link re: libnsl http://www.sunspot.noao.edu/cgi-bin-local/man-cgi?libnsl+4