User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Aug 2005
Location: Bosnia and Herzegovina
Posts: 147
Reputation: Micko is on a distinguished road 
Rep Power: 4
Solved Threads: 1
Micko Micko is offline Offline
Junior Poster

MSVC++ liking issue

  #1  
Nov 9th, 2005
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
#pragma comment(lib, "wsock32.lib")
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Tucson, Az
Posts: 107
Reputation: prog-bman is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 2
prog-bman prog-bman is offline Offline
Junior Poster

Re: MSVC++ liking issue

  #2  
Nov 9th, 2005
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.
Reply With Quote  
Join Date: Jun 2005
Location: Tokyo, Japan
Posts: 1,480
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Rep Power: 8
Solved Threads: 98
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: MSVC++ liking issue

  #3  
Nov 9th, 2005
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 8:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC