LNK 2019:未解决的外部符号 [英] LNK 2019: Unresolved External Symbol

查看:87
本文介绍了LNK 2019:未解决的外部符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

// 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 the Log function declared in class CMainFrame.

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 as const char* and not char const*...


Maybe you don''t include the corresponding header file.


这篇关于LNK 2019:未解决的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆