?
Solved

error LNK2001: unresolved external symbol __imp__WSACleanup@0

Posted on 2006-11-30
14
Medium Priority
?
3,506 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

809 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