未解析的外部符号-仅在释放模式下
Unresolved External Symbol - Only in Release mode
我使用的是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的类,CReportDoc派生自MFC框架的CDocument。
以下是函数声明:
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;
}
我真的不知道如何解决这个问题,这些方法不在任何库中,而且类编译得很好,所以我不知道为什么它在链接时看不到它们。有人有什么想法吗?
编辑:以下是我的项目选项:
发布项目选项:
(Project Settings
的C/C++
选项卡)
/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
(Project Settings
的Link
选项卡)
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"
第102行,位于pastebin.com/e1E0WcBT:
#ifdef _DEBUG
导致在发布模式下构建时从那时起跳过成员函数的所有定义。
相关文章:
- C++ 在释放模式下未初始化为空的向量
- ActiveX OCX可以在释放模式内置时注册,但不能在调试模式下注册
- 仅在64位释放模式中的位移位非法指令
- 内存转储未在C++释放模式下写入
- 如何避免在窗口上以释放模式"program.exe has stopped working"窗口?
- 释放模式下的 Windbg 不起作用
- 在释放模式下,cout 不打印任何内容
- 密钥释放事件在全屏模式下未触发
- 在释放模式下运行程序
- 释放模式跳过部分代码
- 未解析的外部符号-仅在释放模式下
- 释放模式下的boost线程崩溃
- 释放模式是一种特殊模式吗
- 释放模式仍然依赖于MSVCP110D.dll (c++ MSVS)
- 在释放模式下访问时矢量大小为0
- 如何使boost在释放模式下运行
- 释放模式下的访问违规
- 在初始化列表中创建单例对象会导致访问冲突(仅释放模式)
- 为什么短模量在释放模式下不正确
- 当使用C++目标的释放模式时,为什么这个Haxe try-catch块仍然崩溃