error LNK2001: unresolved external symbol __endthreadex
error LNK2001: unresolved external symbol __beginthreadex
fatal error LNK1120: 2 unresolved externals
項目配置為「Win32 Console Application」且勾選「Support MFC」,但運行時庫設置不匹配:代碼使用 MFC 共享 DLL,鏈接器卻默認靜態運行時庫,缺少 _beginthreadex 等 CRT 入口符號。
/MDd / /MD。#include
#include
CWinApp theApp;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) {
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) {
nRetCode = 1;
} else {
CString strHello(_T("Hello MFC Console"));
AfxMessageBox(strHello);
std::cout << (LPCTSTR)strHello << std::endl;
}
return nRetCode;
}
新浪博客《VC6 控制台 MFC 程序配置詳解》:https://blog.sina.com.cn/s/blog_64ecfc2f0100z327.html