By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,780 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,780 IT Pros & Developers. It's quick & easy.

Lnk2001 unresolved external symbols when calling socket functions

P: 2
I need a hand with some stubborn link errors.

I'm trying to recreate and old program from 6.0 into .NET, but for some reason when I try to compile I'm getting linking errors for all my function calls that deal with sockets. I've included <winsock2.h> in stdafx.h and I linked to ws2_32.lib by going to project properties->linker->general->additional library directories and typing in ws2_32.lib.

Am I missing some include files or have the wrong library or something to that extent? Perhaps I put the link to the library in the wrong spot in properties or I need to put it in my code somewhere as well. Any feedback would be greatly appreciatted. I'm pasting the errors below.

Thanks,
-Ryan

Linking...
iotake3.obj : error LNK2001: unresolved external symbol "int __stdcall closesocket(unsigned int)" (?closesocket@@$$J14YGHI@Z)

iotake3.obj : error LNK2001: unresolved external symbol "unsigned short __stdcall ntohs(unsigned short)" (?ntohs@@$$J14YGGG@Z)

iotake3.obj : error LNK2001: unresolved external symbol "unsigned long __stdcall ntohl(unsigned long)" (?ntohl@@$$J14YGKK@Z)

iotake3.obj : error LNK2001: unresolved external symbol "int __stdcall ioctlsocket(unsigned int,long,unsigned long *)" (?ioctlsocket@@$$J212YGHIJPAK@Z)

iotake3.obj : error LNK2001: unresolved external symbol "int __stdcall recv(unsigned int,char *,int,int)" (?recv@@$$J216YGHIPADHH@Z)

iotake3.obj : error LNK2001: unresolved external symbol "int __stdcall connect(unsigned int,struct sockaddr const *,int)" (?connect@@$$J212YGHIPBUsockaddr@@H@Z)

iotake3.obj : error LNK2001: unresolved external symbol "unsigned long __stdcall inet_addr(char const *)" (?inet_addr@@$$J14YGKPBD@Z)

iotake3.obj : error LNK2001: unresolved external symbol "unsigned short
__stdcall htons(unsigned short)" (?htons@@$$J14YGGG@Z)

iotake3.obj : error LNK2001: unresolved external symbol "int __stdcall setsockopt(unsigned int,int,int,char const *,int)" (?setsockopt@@$$J220YGHIHHPBDH@Z)

iotake3.obj : error LNK2001: unresolved external symbol "int __stdcall WSAGetLastError(void)" (?WSAGetLastError@@$$J10YGHXZ)

iotake3.obj : error LNK2001: unresolved external symbol "unsigned int __stdcall socket(int,int,int)" (?socket@@$$J212YGIHHH@Z)

iotake3.obj : error LNK2001: unresolved external symbol "int __stdcall WSAStartup(unsigned short,struct WSAData *)" (?WSAStartup@@$$J18YGHGPAUWSAData@@@Z)

iotake3.obj : error LNK2001: unresolved external symbol "unsigned long __stdcall htonl(unsigned long)" (?htonl@@$$J14YGKK@Z)

iotake3.obj : error LNK2001: unresolved external symbol "int __stdcall send(unsigned int,char const *,int,int)" (?send@@$$J216YGHIPBDHH@Z)

C:\Documents and Settings\rmay\My Documents\Visual Studio Projects\iotake3\Debug\iotake3.exe : fatal error LNK1120: 14 unresolved externals
Mar 7 '07 #1
Share this Question
Share on Google+
2 Replies


P: 2
After a whole lot more searching and trial and error I solved the problem. Turns out I was adding ws2_32.lib in the wrong spot. What I needed to do was go to project properties->linker->Input->Additional Dependancies and add the library there. Hopefully this will help someone else in need.

-Ryan
Mar 9 '07 #2

kenobewan
Expert 2.5K+
P: 4,871
Nice job Ryan, thanks for sharing the solution :).
Mar 11 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.