link错误-link4098
libcmtd.lib(tolower.obj) : error LNK2005: __tolower already defined in libcd.lib(tolower.obj)
libcmtd.lib(tolower.obj) : error LNK2005: _tolower already defined in libcd.lib(tolower.obj)
libcd.lib(crt0init.obj) : warning LNK4098: defaultlib "libcmtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
Debug/VGS2DEBUGDLL.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
解决方案:Project -> Settings -> Link -> project option中加入/nodefaultlib:"LIBCMTD"
error LNK2001: unresolved external symbol _main解决办法
解决外部符号错误:_main,[email protected],__beginthreadex
在创建MFC项目时, 不使用MFC AppWizard向导, 如果没有柚煤孟钅坎问? 就会在编译时产生很多连接错误, 如error LNK2001错误, 典型的错误提示有:
libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol [email protected]
msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol [email protected]
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
1. Windows子系统设置错误, 提示:
libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Windows项目要使用Windows子系统, 而不是Console, 可以这样设置:
[Project] --> [Settings] --> 选择"Link"属性页,在Project Options中将/subsystem:console改成/subsystem:windows
2. Console子系统设置错误, 提示:
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol [email protected]
控制台项目要使用Console子系统, 而不是Windows, 设置:
[Project] --> [Settings] --> 选择"Link"属性页,在Project Options中将/subsystem:windows改成/subsystem:console
3. 程序入口设置错误, 提示:
msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol [email protected] s
通常, MFC项目的程序入口函数是WinMain, 如果编译项目的Unicode版本, 程序入口必须改为wWinMainCRTStartup, 所以需要重新设置程序入口: r
[Project] --> [Settings] --> 选择"Link"属性页,在Category中选择Output,再在Entry-point symbol中填入wWinMainCRTStartup, 即可
4. 线程运行时库设置错误, 提示:
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
这是因为MFC要使用多线程时库, 需要更改设置:
[Project] --> [Settings] --> 选择"C/C++"属性页,在Category中选择Code Generation,再在Use run-time library中选择Debug Multithreaded或者multithreaded
其中,
Single-Threaded 单线程静态链接库(release版本)
Multithreaded 多线程静态链接库(release版本)
multithreaded DLL 多线程动态链接库(release版本)
Debug Single-Threaded 单线程静态链接库(debug版本)
Debug Multithreaded 多线程静态链接库(debug版本) Code Generation->Multithread DLL (即实现/MD选项)
int WINAPI RmuGetPaStatus (HANDLE hCom, UCHAR* uStatus, UCHAR flagCrc);
其中,UCHAR*uStatus是一个传递的地址,关联位置可填地址并且在外部利用指针得到值
展开阅读全文