LNK 2019:未解决的外部符号 [英] LNK 2019: Unresolved External Symbol
问题描述
// mainfrm.h enum { logAll = 0xff }; void Log(int nIdx, LPCTSTR lpText, int nType = logAll, LPCTSTR lpDeviceName = NULL); //SesLog.h int m_nDeviceID; CString m_strDeviceName; // SesLog.cpp #include "Mainfrm.h" #include "SesLog.h" void CSessionLog::Log(LPCSTR lpText) { if(m_pParent) m_pParent->Log(m_nDeviceID, lpText, logAll, m_strDeviceName);
错误LNK2019:无法解析的外部符号公共:void __thiscall CMainFrame :: Log(int,char const *,int,char const *)"(?Log @ CMainFrame @@ QAEXHPBDH0 @ Z)在函数"public:void __thiscall CSessionLog:中引用" :Log(char const *)(?Log @ CSessionLog @@ QAEXPBD @ Z)\ SesLog.obj
VS 2010
帮助将不胜感激.
谢谢
链接器找不到在类CMainFrame
中声明的Log
函数.
您在 MainFrm.h 中进行了此声明:
void Log( int arg1, const * arg2, char // 此函数实现不存在. // 您评论了吗? 无效 CMainFrame :: Log( int arg1, char const * arg2, int arg3, char const * arg4) { .... }
顺便说一句,我想您想将char指针参数声明为const char*
而不是char const*
...
也许您不包括相应的头文件. /blockquote>
// mainfrm.h enum { logAll = 0xff }; void Log(int nIdx, LPCTSTR lpText, int nType = logAll, LPCTSTR lpDeviceName = NULL); //SesLog.h int m_nDeviceID; CString m_strDeviceName; // SesLog.cpp #include "Mainfrm.h" #include "SesLog.h" void CSessionLog::Log(LPCSTR lpText) { if(m_pParent) m_pParent->Log(m_nDeviceID, lpText, logAll, m_strDeviceName);
error LNK2019: unresolved external symbol "public: void __thiscall CMainFrame::Log(int,char const *,int,char const *)" (?Log@CMainFrame@@QAEXHPBDH0@Z) referenced in function "public: void __thiscall CSessionLog::Log(char const *)" (?Log@CSessionLog@@QAEXPBD@Z) \SesLog.obj
VS 2010
Help would be appreciated.
Thanks解决方案The linker couldn''t find theLog
function declared in classCMainFrame
.
You did this declaration in MainFrm.h:
void Log(int arg1, char const * arg2, int arg3, char const * arg4);
But you didn''t write the implementation for this function anywhere. Check your MainFrm.cpp file and make sure you didn''t forget or maybe commented it:
//this function implementation doesn't exist. //did you comment it? void CMainFrame::Log(int arg1, char const * arg2, int arg3, char const * arg4) { .... }
By the way, I suppose you want to declare you char pointers parameters asconst char*
and notchar const*
...
Maybe you don''t include the corresponding header file.
这篇关于LNK 2019:未解决的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!