471,620 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,620 software developers and data experts.

Lnk2001 unresolved external symbols when calling socket functions

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
2 6962
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
4,871 Expert 4TB
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.

Similar topics

3 posts views Thread by We need more power captain | last post: by
2 posts views Thread by ozgan.net | last post: by
2 posts views Thread by Ian Taite | last post: by
2 posts views Thread by Angus | last post: by
1 post views Thread by mahricky | last post: by
reply views Thread by Ryan Gaffuri | last post: by
1 post views Thread by XIAOLAOHU | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.