Thread: linux - lsocket

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    5

    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

  2. #2
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    Posts
    555
    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++.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 11:40 AM
  2. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 11:03 AM
  3. Dabbling with Linux.
    By Hunter2 in forum Tech Board
    Replies: 21
    Last Post: 04-21-2005, 04:17 PM
  4. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM