Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

aaronw1986

macrumors 68030
Original poster
Oct 31, 2006
2,622
10
I have a programming assignment dealing with sockets. My professor said we might need to compile using -lsocket. However, I receive, "/usr/bin/ld: can't locate file for: -lsocket" when I try to do so. Do I not need to use this command in OS X?
 

toddburch

macrumors 6502a
Dec 4, 2006
748
0
Katy, Texas
I've started writing a sockets program myself. Other than pulling in the appropriate header files, I'm just using a "Standard Tool" project in XCode and I have added no additional libraries.

Code:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>

// for struct sockaddr_in 
#include <netinet/in.h> 

// for memset 
#include <strings.h> 

// for getprotoent   
#include <netdb.h>

Todd
 

stupidregister

macrumors member
Sep 29, 2007
52
0
I have a programming assignment dealing with sockets. My professor said we might need to compile using -lsocket. However, I receive, "/usr/bin/ld: can't locate file for: -lsocket" when I try to do so. Do I not need to use this command in OS X?

You don't need that argument. The socket library is not a separate library like in you professor's system (presumably Solaris).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.