-
linux - lsocket
Hello,
Does linux automatically link lsocket if you are using it in a program?
I ask because I can compile my program and it works fine using:
#g++ wisdom.cc
but im supposed to use a make file which contains:
Code:
CCC= g++ -Dsocklen_t=int
LLIB= -lsocket -lnsl
wisdom: wisdom.o
$(CCC) -o wisdom wisdom.o $(LLIB)
but when i run this I get the following:
Code:
g++ -Dsocklen_t=int -o wisdom wisdom.o -lsocket -lnsl
/usr/lib/gcc-lib/i586-suse-linux/3.3.1/../../../../i586-suse-linux/bin/ld: canno
t find -lsocket
collect2: ld returned 1 exit status
make: *** [wisdom] Error 1
I guess im just wondering what is exactly going on.
Thanks.
-matt
-
i dont believe you need to explicitly link the socket library, my programs dont....and if you're using C code you should probably use gcc instead of g++.
-
I concur. If you're not trying to link to a specificly designed socket library, and are using "standard" BSD/unix sockets, you don't need to link. Just use the correct includes. Now, if you've got a custom socket library already compiled and waiting for you, sure, go ahead and link. But if you're just using the "standard" *nix socket functions (open, fcntl, bind, whatever), then there is no need.
Quzah.