2

Visual C ++ 6を使用していて、アプリケーションはデバッグモードで正常にビルドおよび実行されますが、リリースモードでビルドしようとすると、次の2つの未解決の外部シンボルエラーが発生します。

OverUnderReportDoc.obj : error LNK2001: unresolved external symbol "public: virtual int     __thiscall COverUnderReportDoc::GenerateReport(void)" (? GenerateReport@COverUnderReportDoc@@UAEHXZ)

OverUnderReportDoc.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall COverUnderReportDoc::DoReport(void)" (?DoReport@COverUnderReportDoc@@UAE_NXZ)

COverUnderReportDocは、MFCフレームワークの一部であるCDocumentから派生したCReportDocから派生したクラスです。

関数宣言は次のとおりです。

public:

virtual int GenerateReport(void);
virtual bool DoReport(void);

そして定義:

bool COverUnderReportDoc::DoReport(void)
{

// Instantiate the dialog
CCriteriaDlg dlg;
m_Report.BreakSpace(FALSE);

// Get a pointer to the window
CWnd* pWnd = AfxGetApp()->m_pMainWnd;

// When OK is clicked...
if (dlg.DoModal() == IDOK)
{       
    // Set the document title
    SetTitle("Inventory Over/Under");

    // Copy some values from the dialog to member variables

    GenerateReport();

    pWnd->ShowWindow(SW_MAXIMIZE);

}
else
{
            // If Cancel is clicked, close the program
    if(pWnd)
        pWnd->PostMessage(WM_CLOSE);
    return false;
}

return true;
}

int COverUnderReportDoc::GenerateReport(void)
{

// write the headers to the report
// if there was no problem
if (DoHeaders())
{
    // assemble the report data
    // if that went well
    if (ScanFile())
        // write the summary to the report
        DoSummary();
}
// return the document status
return m_nStatus;
}

これを解決する方法が本当にわかりません。これらのメソッドはどのライブラリにも存在せず、クラスは正常にコンパイルされるため、リンク中にそれらが表示されない理由がわかりません。誰かアイデアはありますか?

編集:これが私のプロジェクトオプションです:

プロジェクトオプションのリリース:

C/C++のタブProject Settings

/nologo /Zp1 /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D   "_MBCS" /D "BTI_WIN_32" /FR"Release/" /Fo"Release/" /Fd"Release/" /FD /c 

LinkのタブProject Settings

MYLIB.lib w3btrv7.lib VERSION.LIB /nologo /subsystem:windows /incremental:no /pdb:"Release/OverUnderReport.pdb" /machine:I386 /out:"Release/OverUnderReport.exe" 

デバッグプロジェクトオプション:

C/C++のタブProject Settings

/nologo /Zp1 /MDd /W3 /GX /ZI /Ot /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /D "BTI_WIN_32" /FR"Debug/" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c

LinkのタブProject Settings

VERSION.LIB MYLIB.lib w3btrv7.lib /nologo /subsystem:windows /profile /debug /machine:I386 /out:"Debug/OverUnderReport.exe" 
4

1 に答える 1

4

Pastebin.com/e1E0WcBTの行#102:

#ifdef _DEBUG

リリースモードでビルドすると、その時点からメンバー関数のすべての定義がスキップされます。

于 2012-01-06T21:48:50.023 に答える