I downloaded a project which was originally developed in MFC 4.1. I'm trying to build that project in MFC 6.0. When I opened it using Open WorkSpace
, and build it, then following error came.
Link : fatal error LNK1104: cannot open file "mfc42ud.lib"
On internet I found a solution to fix this error by ignoring this library from Project settings. I did that and then another error on similar lines appeared for mfcs42ud.lib
file. And I fixed that too.
When I added both the .lib files to ignore list, and build it, then I'm getting 901 errors like below....
--------------------Configuration: doodads - Win32 Unicode Debug-------------------- Linking... doodads.obj :
error LNK2001: unresolved external symbol __afxForceEXCLUDE ADDRESS.OBJ : error LNK2001: unresolved external symbol __afxForceEXCLUDE expose.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE progress.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE MaskDlg.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE SETKEY.OBJ : error LNK2001: unresolved external symbol __afxForceEXCLUDE SPINNER.OBJ : error LNK2001: unresolved external symbol __afxForceEXCLUDE stats.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE ANIME.OBJ : error LNK2001: unresolved external symbol __afxForceEXCLUDE STDAFX.OBJ : error LNK2001: unresolved external symbol __afxForceEXCLUDE MAINFRM.OBJ : error LNK2001: unresolved external symbol __afxForceEXCLUDE DODADDOC.OBJ : error LNK2001: unresolved external symbol __afxForceEXCLUDE DoDadvw.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE doodads.obj : error LNK2001: unresolved external symbol __afxForceSTDAFX ADDRESS.OBJ : error LNK2001: unresolved external symbol __afxForceSTDAFX expose.obj : error LNK2001: unresolved external symbol __afxForceSTDAFX progress.obj : error LNK2001: unresolved external symbol __afxForceSTDAFX MaskDlg.obj : error LNK2001: unresolved external symbol __afxForceSTDAFX SETKEY.OBJ : error LNK2001: unresolved external symbol __afxForceSTDAFX SPINNER.OBJ : error LNK2001: unresolved external symbol __afxForceSTDAFX stats.obj : error LNK2001: unresolved external symbol __afxForceSTDAFX ANIME.OBJ : error LNK2001: unresolved external symbol __afxForceSTDAFX STDAFX.OBJ : error LNK2001: unresolved external symbol __afxForceSTDAFX MAINFRM.OBJ : error LNK2001: unresolved external symbol __afxForceSTDAFX DODADDOC.OBJ : error LNK2001: unresolved external symbol __afxForceSTDAFX DoDadvw.obj : error LNK2001: unresolved external symbol __afxForceSTDAFX
Here is the code file for your reference.
Add.h
// ADD.H - Header file for your Internet Server
// add Extension
#include "resource.h"
class CAddExtension : public CHttpServer
{
public:
CAddExtension();
~CAddExtension();
// Overrides
// ClassWizard generated virtual function overrides
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//{{AFX_VIRTUAL(CAddExtension)
public:
virtual BOOL GetExtensionVersion(HSE_VERSION_INFO* pVer);
//}}AFX_VIRTUAL
// TODO: Add handlers for your commands here.
// For example:
void Default(CHttpServerContext* pCtxt,
LPCTSTR pstrOp1, LPCTSTR pstrOp2);
DECLARE_PARSE_MAP()
//{{AFX_MSG(CAddExtension)
//}}AFX_MSG
};
Add.cpp
// ADD.CPP - Implementation file for your Internet Server
// add Extension
#include "stdafx.h"
#include "add.h"
#include <stdio.h>
///////////////////////////////////////////////////////////////////////
// command-parsing map
BEGIN_PARSE_MAP(CAddExtension, CHttpServer)
// TODO: insert your ON_PARSE_COMMAND() and
// ON_PARSE_COMMAND_PARAMS() here to hook up your commands.
// For example:
ON_PARSE_COMMAND(Default, CAddExtension, ITS_PSTR ITS_PSTR)
ON_PARSE_COMMAND_PARAMS("opone=~ optwo=~")
DEFAULT_PARSE_COMMAND(Default, CAddExtension)
END_PARSE_MAP(CAddExtension)
///////////////////////////////////////////////////////////////////////
// The one and only CAddExtension object
CAddExtension theExtension;
///////////////////////////////////////////////////////////////////////
// CAddExtension implementation
CAddExtension::CAddExtension()
{
}
CAddExtension::~CAddExtension()
{
}
BOOL CAddExtension::GetExtensionVersion(HSE_VERSION_INFO* pVer)
{
// Call default implementation for initialization
CHttpServer::GetExtensionVersion(pVer);
// Load description string
TCHAR sz[HSE_MAX_EXT_DLL_NAME_LEN+1];
ISAPIVERIFY(::LoadString(AfxGetResourceHandle(),
IDS_SERVER, sz, HSE_MAX_EXT_DLL_NAME_LEN));
_tcscpy(pVer->lpszExtensionDesc, sz);
return TRUE;
}
///////////////////////////////////////////////////////////////////////
// CAddExtension command handlers
void CAddExtension::Default(CHttpServerContext* pCtxt,
LPCTSTR pstrOp1, LPCTSTR pstrOp2)
{
StartContent(pCtxt);
WriteTitle(pCtxt);
int nOp1;
int nOp2;
if (*pstrOp1 != '~' && *pstrOp2 != '~')
{
nOp1 = atoi(pstrOp1);
nOp2 = atoi(pstrOp2);
char sz[1024];
sprintf(sz, "The result is: %d\n", nOp1 + nOp2);
*pCtxt << sz;
}
else
{
*pCtxt << "<FORM ACTION=\"http://mooseboy/add.dll\" METHOD=\"GET\">";
*pCtxt << "Enter the first number: <INPUT TYPE=\"text\" NAME=\"opone\" VALUE=\"0\" SIZE=10><p>";
*pCtxt << "Enter the second number: <INPUT TYPE=\"text\" NAME=\"optwo\" VALUE=\"0\" SIZE=10><p>";
*pCtxt << "<p> <INPUT TYPE = \"SUBMIT\" VALUE=\"Add it up\">";
*pCtxt << "</FORM>";
}
EndContent(pCtxt);
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CAddExtension, CHttpServer)
//{{AFX_MSG_MAP(CAddExtension)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
///////////////////////////////////////////////////////////////////////
// If your extension will not use MFC, you'll need this code to make
// sure the extension objects can find the resource handle for the
// module. If you convert your extension to not be dependent on MFC,
// remove the comments arounn the following AfxGetResourceHandle()
// and DllMain() functions, as well as the g_hInstance global.
static HINSTANCE g_hInstance;
HINSTANCE AFXISAPI AfxGetResourceHandle()
{
return g_hInstance;
}
BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason,
LPVOID lpReserved)
{
if (ulReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInst;
}
return TRUE;
}
Just for information, I've marked Microsoft Foundation Classes to Use MFC in a shared DLL under General tab. Please help, TIA.
MFC 6.0
uses MFC42*.LIB
library files (strange but true). So it seems you link with the correct filenames.
If you get these error messages when you link your project, I guess that either your project file has something wrong, or Visual C++ 6
is not correctly installed. The solution is not to remove these libraries, but to find out why Visual C++ doesn't find them.
Your project is compiling in unicode-debug
configuration. Have you installed the unicode libraries when you have installed Visual C++
? Maybe this is an opt-in
install option (not sure). Can you build your project using another configuration, like release-unicode? Or Debug?
What can help you is to create a new empty Visual C++/MFC project (File/New Project/C++/MFC/MFC Application)
, so will get a valid MFC project configuration. Be sure to choose Unicode configuration, because this is the configuration you want to use.