(unresolved external symbol __endthreadex解决办法)
1、新建控制台程序:
2、添加源代码如下:
int main()
{
int lo, hi;
CString str;
CStdioFile pFile;
pFile.Open("FIBO.DAT", CFile::modeWrite |
CFile::modeCreate|
CFile::typeText);
str.Format("%s/n", "Fibonacci sequencee, less than 100 :");
printf("%s", (LPCTSTR) str);
pFile.WriteString(str);
lo = hi = 1;
str.Format("%d/n", lo);
printf("%s", (LPCTSTR) str);
pFile.WriteString(str);
while (hi < 100)
{
str.Format("%d/n", hi);
printf("%s", (LPCTSTR) str);
pFile.WriteString(str);
hi = lo + hi;
lo = hi - lo;
}
pFile.Close();
return 0;
}
3、编译是链接出错:
Compiling...
Console.cpp
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/MFCConsole.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Console.exe - 3 error(s), 0 warning(s)
4、分析原因:
上述连接错误表示找不到__endthreadex与__beginthreadex,我们的程序有调用它们吗?没有,但是MFC有(afx.h)
5、解决办法
unresolved external symbol __endthreadex错误解决
A、设置静态链接库
选择Project-Settings--General--Microsoft foundation Classes
下拉列表中有三个选项,选择2/3即可:
1、Not using MFC
2、Use MFC in a Static Libray
3、Use MFC in a Shared DLL
B、设置C Runtime函数库
Project / settings / c/c++ / Catagory / Code Generation
use run-time library”选择“debug multithreaded”
6、关于C Runtime