Jump to content
  • Advertisement
Sign in to follow this  
rajend3

undefined symbol inet_addr

This topic is 4159 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having trouble with this code. I just wanted to see if what I wrote so far had any problems and it did; this is the error I got: Undefined first referenced symbol in file inet_addr client.o This is the code: #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <string.h> #include <errno.h> #define SOURCEPORT 3490 int main() { struct sockaddr_in sourceAddr; sourceAddr.sin_family = AF_INET; sourceAddr.sin_port = htons(SOURCEPORT); sourceAddr.sin_addr.s_addr = inet_addr("10.12.110.57"); memset( sourceAddr.sin_zero, '\0', sizeof sourceAddr.sin_zero); return 0; } Is there a typo in my code or is there an include problem?

Share this post


Link to post
Share on other sites
Advertisement
I'm not really much of a C person, but it looks to me like you are calling a function called "inet_addr" which is not defined in any of the header files you include. Which is weird since it should be in <arpa/inet.h>. If this is a linker error, I guess you are not linking the program properly.

Share this post


Link to post
Share on other sites
Given the error is an undefined symbol referenced in an .o file, it looks like a linker error. Depending on your system you may need one or more of -lnsl -lsocket -lresolv as additional libraries.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!