•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 401,693 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,687 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 1119 | Replies: 2
![]() |
•
•
Join Date: Aug 2005
Location: Bosnia and Herzegovina
Posts: 147
Reputation:
Rep Power: 4
Solved Threads: 1
Hi,
sometimes I get this linker error
LNK2019: unresolved external symbol _WSACleanup@0 referenced in function _main
and sometimes it works OK. Solution is usually to place pragma directive below include directives
First, can someone explain in simple words what this means?
Maybe it's some kind of bug, it seems that problem sometimes rise only in MSVC++.
I use MSVC++ .net v2002
Thank you
sometimes I get this linker error
LNK2019: unresolved external symbol _WSACleanup@0 referenced in function _main
and sometimes it works OK. Solution is usually to place pragma directive below include directives
#pragma comment(lib, "wsock32.lib")
Maybe it's some kind of bug, it seems that problem sometimes rise only in MSVC++.
I use MSVC++ .net v2002
Thank you
•
•
Join Date: Nov 2004
Location: Tucson, Az
Posts: 107
Reputation:
Rep Power: 4
Solved Threads: 2
Well the linking error means it finds the prototype of the function but doesn't find the actual defination of the function. I am not sure why it does that since I would not be an VC++ expert. Maybe look up how the pragma comment has to be.
Join me on IRC:
Server: irc.daniweb.com
Channel: #C++
Chat Via:
http://daniweb.com/chat/minichat.php
or
Your favorite IRC client.
Server: irc.daniweb.com
Channel: #C++
Chat Via:
http://daniweb.com/chat/minichat.php
or
Your favorite IRC client.
•
•
Join Date: Jun 2005
Location: Tokyo, Japan
Posts: 1,480
Reputation:
Rep Power: 8
Solved Threads: 98
If you think that it is a bug in Visual Studio, it is not. Refer the following URL.
#pragma comment
You need to link the wsock32.lib or ws2_32.lib ( Winsock Library ) to use the APIs that are needed for WinSock programming in Windows. Visual Studio by default links the kernel32.lib user32.lib gdi32.lib libraries when you build a project. If you are using other libraries ( e.g. ws2_32.lib, ComCtl32.lib ), you will have to explicitly tell that to the linker.
One way is to use the method you have already used. Other methods are setting the "Additional Libraries Used" field in Project Properties->Linker->Input.
Also you can select add Existing Item to Project and browse for the LIbraries you are using and select them. But this method is not encouraged because this uses Absolute Paths and if you compile it in another machine where the Library Path is different, the linker will fail.
#pragma comment
You need to link the wsock32.lib or ws2_32.lib ( Winsock Library ) to use the APIs that are needed for WinSock programming in Windows. Visual Studio by default links the kernel32.lib user32.lib gdi32.lib libraries when you build a project. If you are using other libraries ( e.g. ws2_32.lib, ComCtl32.lib ), you will have to explicitly tell that to the linker.
One way is to use the method you have already used. Other methods are setting the "Additional Libraries Used" field in Project Properties->Linker->Input.
Also you can select add Existing Item to Project and browse for the LIbraries you are using and select them. But this method is not encouraged because this uses Absolute Paths and if you compile it in another machine where the Library Path is different, the linker will fail.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- What's better? Windows 2000 Server or Linux Server? (Windows Servers and IIS)
- Power boot up issue (Motherboards, CPUs and RAM)
- Kernel Version of Mandrake and error message (*nix Software)
- Memory Issue's! Please Help!! (Motherboards, CPUs and RAM)
- Internet Explorer Connection Issue (Web Browsers)
- Netgear router issue...read this if you have one (Networking Hardware Configuration)
Other Threads in the C++ Forum
- Previous Thread: Help with Array
- Next Thread: Handling Text from a multi-line edit box (win32api with c++)



Linear Mode