I'm using Visual C++ 6, and my application builds and runs fine in debug mode, but I get these two Unresolved External Symbol errors when trying to build in Release mode:
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 is a class derived from CReportDoc, which is derived from CDocument, part of the MFC framework.
Here are the function declarations:
public:
virtual int GenerateReport(void);
virtual bool DoReport(void);
And the definitions:
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;
}
I'm really not sure how to resolve this, those methods aren't in any libraries, and the class compiles fine, so I don't know why it doesn't see them while linking. Anyone have any ideas?
EDIT: Here are my project options:
Release Project Options:
(C/C++
tab of 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
tab of Project Settings
)
MYLIB.lib w3btrv7.lib VERSION.LIB /nologo /subsystem:windows /incremental:no /pdb:"Release/OverUnderReport.pdb" /machine:I386 /out:"Release/OverUnderReport.exe"
Debug Project options:
(C/C++
tab of 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
tab of Project Settings
)
VERSION.LIB MYLIB.lib w3btrv7.lib /nologo /subsystem:windows /profile /debug /machine:I386 /out:"Debug/OverUnderReport.exe"
Line #102 at pastebin.com/e1E0WcBT :
#ifdef _DEBUG
results in skipping all definitions of member functions from that point when built in release mode.