Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Winsock.DLL

Hi all!

I am using the Winsock.dll functions for communication software with MSVC++ V6, but I am getting the linker error like that:
1. err.obj : error LNK2001: unresolved external symbol _WSASetLastError@4
2. sock.obj : error LNK2001: unresolved external symbol __imp__ntohs@4
and etc.

it means the linker don't find the winsock.DLL file. my question is how I can tell the linker to link the Winsock.DLL, which I know excatly where is located ?
[482 byte] By [nivrobin] at [2007-11-11 10:06:26]
# 1 Re: Winsock.DLL
To use this dll you need to link in the LIB file. There should be a winsock.lib file that you add to the project.
jonnin at 2007-11-11 20:59:27 >
# 2 Re: Winsock.DLL
if it's in the <systemdir> or in the <library files dir for your vc> or the same dir as the source programme , u don't need to link to it as the linker search in those dirs first ...

otherwise u can manage this from :
project>>settings (ALT+F7) >>link > customize
Amahdy at 2007-11-11 21:00:27 >
# 3 Re: Winsock.DLL
I think in Windows 95 and later the correct library is actually called "Ws2_32.lib".

You can specify it in Projects settings (Link --> Category: Input --> Object/library modules), or in one of your source file:
#pragma comment(lib, "Ws2_32.lib")
I hope this helps.
Viorel at 2007-11-11 21:01:33 >
# 4 Re: Winsock.DLL
Hi all !

Thanks for the reply. I look at the files and see that I no winsock.lib.. it means that i need it. how can I get it ? from where ?
nivrobin at 2007-11-11 21:02:27 >
# 5 Re: Winsock.DLL
google to winsock.lib , u will find too many sites supporting it .
Amahdy at 2007-11-11 21:03:26 >
# 6 Re: Winsock.DLL
Its in the install folders of visual c++ somewhere. Press f3 and search or try installed folder\c++\lib and \c++\include areas
jonnin at 2007-11-11 21:04:31 >
# 7 Re: Winsock.DLL
Thanks it help !
nivrobin at 2007-11-11 21:05:35 >
# 8 Re: Winsock.DLL
Really u found it in your machine ? why I never got it after my installation ?? in vc6 and .net too !
Amahdy at 2007-11-11 21:06:38 >
# 9 Re: Winsock.DLL
It should be there, or possible in the platform sdks which I always install. It may matter what version you have. I have the expensive vc 6.0 and the c++ only cheap 2002 .net installed atm.
jonnin at 2007-11-11 21:07:31 >
# 10 Re: Winsock.DLL
Usually I use vc6 but sometimes I refer to the installed .net 2003 and rarely I need to install the .net 2005 and no one of them contains the .lib file , anyway I prefer to use the winsock.ocx coz it's easiest to use at coding time , but at final compilation sometimes I refer to the dll with small changes in the source programme .
Amahdy at 2007-11-11 21:08:37 >