我使用Visual C++ 6,和我的應用程序生成並運行在調試模式很好,但我在嘗試建立在Release模式時,這兩個解析外部符號錯誤:解析的外部符號 - 只有在釋放模式
OverUnderReportDoc.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall COverUnderReportDoc::GenerateReport(void)" (? [email protected]@@UAEHXZ)
OverUnderReportDoc.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall COverUnderReportDoc::DoReport(void)" ([email protected]@@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
)
Link
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
MYLIB.lib w3btrv7.lib VERSION.LIB /nologo /subsystem:windows /incremental:no /pdb:"Release/OverUnderReport.pdb" /machine:I386 /out:"Release/OverUnderReport.exe"
個
調試項目選項:(標籤Project Settings
C/C++
)
/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
(的Project Settings
Link
標籤)
VERSION.LIB MYLIB.lib w3btrv7.lib /nologo /subsystem:windows /profile /debug /machine:I386 /out:"Debug/OverUnderReport.exe"
通常不會調試和發佈版本之間的工作的東西的原因是配置設置和/或編譯器優化。你還公開繼承了'CReportDoc'嗎? 'COverUnderReportDoc:公共CReportDoc' – Joe 2012-01-06 20:18:36
是,'COverUnderReportDoc'公開從'CReportDoc'繼承。我要添加項目選項原帖爲好,因爲我真的不知道我在看/與那些... – NobodyNothing 2012-01-06 20:23:04
出於好奇,你有沒有進行清潔,然後建立? – hmjd 2012-01-06 20:48:16