简体   繁体   English

在MFC 6.0中建立MFC 4.1专案时发生错误

[英]Error while building MFC 4.1 project in MFC 6.0

I downloaded a project which was originally developed in MFC 4.1. 我下载了最初在MFC 4.1中开发的项目。 I'm trying to build that project in MFC 6.0. 我正在尝试在MFC 6.0中构建该项目。 When I opened it using Open WorkSpace , and build it, then following error came. 当我使用Open WorkSpace打开它并进行构建时,出现以下错误。

Link : fatal error LNK1104: cannot open file "mfc42ud.lib" 链接:致命错误LNK1104:无法打开文件“ mfc42ud.lib”

On internet I found a solution to fix this error by ignoring this library from Project settings. 在Internet上,我找到了一种解决方案,可以通过从Project设置中忽略此库来解决此错误。 I did that and then another error on similar lines appeared for mfcs42ud.lib file. 我这样做了,然后在mfcs42ud.lib文件的相似行上出现了另一个错误。 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.... 当我将两个.lib文件添加到忽略列表并进行构建时,出现如下所示的901错误...。

--------------------Configuration: doodads - Win32 Unicode Debug-------------------- Linking... doodads.obj : --------------------配置:doodads-Win32 Unicode调试--------------------链接。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 _ 错误LNK2001:无法解析的外部符号__afxForceEXCLUDE ADDRESS.OBJ:错误LNK2001:无法解析的外部符号__afxForceEXCLUDE exclude.obj:错误LNK2001:无法解析的外部符号__afxForceEXCLUDE progress.obj:错误LNK2001:无法解析的外部符号__afxForceEXC __afxForceEXCLUDE SETKEY.OBJ:错误LNK2001:无法解析的外部符号__afxForceEXCLUDE SPINNER.OBJ:错误LNK2001:无法解析的外部符号__afxForceEXCLUDE stats.obj:错误LNK2001:无法解析的外部符号__afxForceEXCEXCLUDE STEKL:ERROR:LNK2001:错误LNK2001:未解析的外部符号LNK2001:无法解析的外部符号__afxForceEXCLUDE MAINFRM.OBJ:错误LNK2001:无法解析的外部符号__afxForceEXCLUDE DODADDOC.OBJ:错误LNK2001:无法解析的外部符号__afxForceEXCLUDE DoDadvw.obj:错误LNK2001:无法解析的外部符号__错误: _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 _afxForceSTDAFX ADDRESS.OBJ:错误LNK2001:无法解析的外部符号__afxForceSTDAFX暴露.obj:错误LNK2001:无法解析的外部符号__afxForceSTDAFX progress.obj:错误LNK2001:无法解析的外部符号__afxForceSTDAFX MaskDlg.obj:错误LNK2001:无法解析的LNK2001:无法解析的外部符号__afxForceSTDAFX SPINNER.OBJ:错误LNK2001:无法解析的外部符号__afxForceSTDAFX stats.obj:错误LNK2001:无法解析的外部符号__afxForceSTDAFX ANIME.OBJ:错误LNK2001:无法解析的外部符号__afxForce: MAINFRM.OBJ:错误LNK2001:未解析的外部符号__afxForceSTDAFX DODADDOC.OBJ:错误LNK2001:未解析的外部符号__afxForceSTDAFX DoDadvw.obj:错误LNK2001:未解析的外部符号__afxForceSTDAFX

Here is the code file for your reference. 这是代码文件供您参考。

Add.h 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

// 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. 仅供参考,我在“常规”选项卡下的共享DLL中将Microsoft基础类标记为使用MFC。 Please help, TIA. 请帮助,TIA。

MFC 6.0 uses MFC42*.LIB library files (strange but true). MFC 6.0使用MFC42*.LIB库文件(奇怪但正确)。 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. 如果在链接项目时收到这些错误消息,则可能是项目文件有问题或Visual C++ 6未正确安装。 The solution is not to remove these libraries, but to find out why Visual C++ doesn't find them. 解决方案不是删除这些库,而是找出为什么Visual C ++找不到它们。

Your project is compiling in unicode-debug configuration. 您的项目正在unicode-debug配置中进行编译。 Have you installed the unicode libraries when you have installed Visual C++ ? 安装Visual C++是否已安装unicode库? Maybe this is an opt-in install option (not sure). 也许这是一个opt-in安装选项(不确定)。 Can you build your project using another configuration, like release-unicode? 您可以使用其他配置(例如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. 能帮助您的是创建一个新的空Visual C ++ / MFC项目(File/New Project/C++/MFC/MFC Application) ,这样将获得有效的MFC项目配置。 Be sure to choose Unicode configuration, because this is the configuration you want to use. 请确保选择Unicode配置,因为这是您要使用的配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM