Solved

error LNK2001: unresolved external symbol __imp__WSACleanup@0

Posted on 2006-11-30
14
3,439 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 4

Expert Comment

by:bdunz19
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
well then may be missing is #include <winsock2.h>

-MAHESH
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 4

Accepted Solution

by:
bdunz19 earned 500 total points
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
if that working with afxsock.h, it should also work with manually linking with wsock32.lib and without afxsock.h !
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now