Неразрешенный внешний символ - только в режиме разблокировки - PullRequest
2 голосов
/ 06 января 2012

Я использую Visual C ++ 6, и мое приложение собирается и работает нормально в режиме отладки, но я получаю эти две неразрешенные ошибки внешнего символа при попытке построить в режиме выпуска:

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 - это класс, производный от CReportDoc, который является производным от CDocument, части инфраструктуры MFC.

Вот объявления функций:

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" 

Ответы [ 2 ]

3 голосов
/ 07 января 2012

Строка # 102 на pastebin.com/e1E0WcBT:

#ifdef _DEBUG

приводит к пропуску всех определений функций-членов с этой точки при построении в режиме выпуска.

1 голос
/ 07 января 2012
...