Solved

error LNK2001: unresolved external symbol __imp__WSACleanup@0

Posted on 2006-11-30
14
3,454 Views
Last Modified: 2013-11-20
Hi guys,

I am compiling my application in Release Mode (Debug Mode compiles no problem), and am getting these errors:

CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__WSACleanup@0
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__connect@12
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__htons@4
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__inet_addr@4
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__setsockopt@20
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__socket@12
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__WSAStartup@8
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__send@16
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__closesocket@4
CustomBrowserDlg.obj : error LNK2001: unresolved external symbol __imp__recv@16
Release/CustomBrowser.exe : fatal error LNK1120: 11 unresolved externals


Any idea how to fix these?

Cheers!
0
Comment
Question by:Cyber-Drugs
  • 7
  • 4
  • 3
14 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 18046437
You need to specify the winsock library project->settings->link.

In the project->settings->link, add this ws2_32.lib.

-MAHESH
0
 
LVL 4

Expert Comment

by:bdunz19
ID: 18046447
Hey Cyber,

Make sure the statement #include <afxsock.h> is in your stdafx.h and is not surrounded by any #ifdef DEBUG_MODE or anything like that...

Heck try just including <afxsock.h> and see if that works.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 18046469
above are linker errors due to missing winsock library to link with ur project

So try adding ws2_32.lib to project->settings->link first.. that should solve your problem.

-MAHESH
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 4

Expert Comment

by:bdunz19
ID: 18046485
MAHESH,

In MFC, I don't believe it is neccisary to include the winsock library as long as afxsock.h is included.
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18046497
Mahesh,

I already have that file inside there, any other ideas?



Brandon,

When I add that to stdafx.h, I get 240+ errors...
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 18046508
well I think you should link wsock32.lib or ws2_32.lib as its failing at linker level.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 18046515
well then may be missing is #include <winsock2.h>

-MAHESH
0
 
LVL 4

Accepted Solution

by:
bdunz19 earned 500 total points
ID: 18046541
Haha, that's rather odd! Make sure there is not already included winsock.h.

I'm pretty sure afxsock.h is what you need.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 18046545
>>I already have that file inside there, any other ideas?

are you sure you are linking with : ws2_32.lib
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18046573
Brandon, I'll have a quick look and see...

Mahesh, I just double checked, and yes I am linking with that file already.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 18046575
well afxsock.h includes #pragma comment(lib, "wsock32.lib") statement which equal to linking with wsock32.lib.. as I said before you need to link with that anyway with afxsock.h or manually linking !!!
0
 
LVL 4

Author Comment

by:Cyber-Drugs
ID: 18046588
Brandon,

I replaced winsock.h to afxsock.h

It now compiles with other errors (which I expected), cheers!
0
 
LVL 4

Expert Comment

by:bdunz19
ID: 18046594
Yeah, I just realized that because you are linking manually to ws2_32.lib, that is most likely going to cause some problems. So either stick to ws2_32.lib/winsock.h or remove those and simply include afxsock.h

Hope that solves it
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 18046604
if that working with afxsock.h, it should also work with manually linking with wsock32.lib and without afxsock.h !
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question