本人在学习侯老师的 < <深入浅出MFC> > 时,第三章的Frame1程序,开始新建Win32 一个空的Console Application,然后把书中的代码如实写上去,编译错误如下:
error LNK2019: 无法解析的外部符号 "public: __thiscall CCmdTarget::CCmdTarget(void)" (??0CCmdTarget@@QAE@XZ),该符号在函数 "public: __thiscall CWnd::CWnd(void)" (??0CWnd@@QAE@XZ) 中被引用
1>my.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall CCmdTarget::~CCmdTarget(void)" (??1CCmdTarget@@QAE@XZ),该符号在函数 "public: __thiscall CWnd::~CWnd(void)" (??1CWnd@@QAE@XZ) 中被引用
1>my.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall CMyWinApp::CMyWinApp(void)" (??0CMyWinApp@@QAE@XZ),该符号在函数 "void __cdecl `dynamic initializer for 'theApp''(void)" (??__EtheApp@@YAXXZ) 中被引用
1>my.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall CMyWinApp::~CMyWinApp(void)" (??1CMyWinApp@@QAE@XZ),该符号在函数 "void __cdecl `dynamic atexit destructor for 'theApp''(void)" (??__FtheApp@@YAXXZ) 中被引用
error LNK2019: 无法解析的外部符号 "public: __thiscall CCmdTarget::CCmdTarget(void)" (??0CCmdTarget@@QAE@XZ),该符号在函数 "public: __thiscall CWnd::CWnd(void)" (??0CWnd@@QAE@XZ) 中被引用
1>my.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall CCmdTarget::~CCmdTarget(void)" (??1CCmdTarget@@QAE@XZ),该符号在函数 "public: __thiscall CWnd::~CWnd(void)" (??1CWnd@@QAE@XZ) 中被引用
1>my.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall CMyWinApp::CMyWinApp(void)" (??0CMyWinApp@@QAE@XZ),该符号在函数 "void __cdecl `dynamic initializer for 'theApp''(void)" (??__EtheApp@@YAXXZ) 中被引用
1>my.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall CMyWinApp::~CMyWinApp(void)" (??1CMyWinApp@@QAE@XZ),该符号在函数 "void __cdecl `dynamic atexit destructor for 'theApp''(void)" (??__FtheApp@@YAXXZ) 中被引用
楼主创建工程的时候注意一下有个MFC的选项,那个选项不要选
只创建单纯的Win32工程
然后重新尝试编译
Project-> Setting ->General -> use MFC in a Static Libray
这样也许就OK了
然后楼上几位都提出要建立MFC工程看过那章节内容就知道,那个示例程序是需要使用win32工程演示的, 而不能参杂MFC的元素