Cyber-Drugs
asked on
error LNK2001: unresolved external symbol __imp__WSACleanup@0
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!
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!
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.
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.
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
So try adding ws2_32.lib to project->settings->link first.. that should solve your problem.
-MAHESH
MAHESH,
In MFC, I don't believe it is neccisary to include the winsock library as long as afxsock.h is included.
In MFC, I don't believe it is neccisary to include the winsock library as long as afxsock.h is included.
ASKER
Mahesh,
I already have that file inside there, any other ideas?
Brandon,
When I add that to stdafx.h, I get 240+ errors...
I already have that file inside there, any other ideas?
Brandon,
When I add that to stdafx.h, I get 240+ errors...
well I think you should link wsock32.lib or ws2_32.lib as its failing at linker level.
well then may be missing is #include <winsock2.h>
-MAHESH
-MAHESH
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>I already have that file inside there, any other ideas?
are you sure you are linking with : ws2_32.lib
are you sure you are linking with : ws2_32.lib
ASKER
Brandon, I'll have a quick look and see...
Mahesh, I just double checked, and yes I am linking with that file already.
Mahesh, I just double checked, and yes I am linking with that file already.
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 !!!
ASKER
Brandon,
I replaced winsock.h to afxsock.h
It now compiles with other errors (which I expected), cheers!
I replaced winsock.h to afxsock.h
It now compiles with other errors (which I expected), cheers!
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
Hope that solves it
if that working with afxsock.h, it should also work with manually linking with wsock32.lib and without afxsock.h !
In the project->settings->link, add this ws2_32.lib.
-MAHESH