Solved

error LNK2001: unresolved external symbol __imp__WSACleanup@0

Posted on 2006-11-30
14
3,446 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

920 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

12 Experts available now in Live!

Get 1:1 Help Now