Visual C 运行时函数无法用 `/MT` 解析 [英] Visual C Runtime functions unresolved with `/MT`

查看:41
本文介绍了Visual C 运行时函数无法用 `/MT` 解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将大型 Visual Studio 解决方案从 VS 2010 转换为 VS 2017.该解决方案中的一个项目仅包含 C,不包含 C++,并使用 /MT 编译以与多线程 C 运行时.

I'm converting a large Visual Studio solution from VS 2010 to VS 2017. One of the projects in the solution contains only C, no C++, and compiles with /MT to link statically with the multi-threaded C runtime.

不幸的是,链接器似乎没有找到 C 运行时函数,即使 libcmt.lib 在库列表中.链接器实际上说在详细输出中未使用此库.

Unfortunately, the C runtime functions don't seem to be getting found by the linker, even though libcmt.lib is in the list of libraries. The linker actually says that this lib is unused in the verbose output.

为什么链接器找不到函数?

Why is the linker not finding the functions?

输出:

redacted.obj : error LNK2019: unresolved external symbol memcpy referenced in function FsConvertAndFreeInformation
redacted.obj : error LNK2019: unresolved external symbol memset referenced in function FsInitDebugSocket
msvcrt.lib(utility_desktop.obj) : error LNK2001: unresolved external symbol memset
redacted.obj : error LNK2019: unresolved external symbol wcsstr referenced in function FsGetTokenInformation
redacted.obj : error LNK2019: unresolved external symbol wcscat_s referenced in function FsGetTokenInformation
redacted.obj : error LNK2019: unresolved external symbol wcsncpy_s referenced in function FsGetTokenInformation
redacted.obj : error LNK2019: unresolved external symbol _wcsdup referenced in function LsaApLogonUserEx2
redacted.obj : error LNK2019: unresolved external symbol wcscpy referenced in function SetUnicodeString
redacted.obj : error LNK2019: unresolved external symbol wcslen referenced in function FsDebugLog
redacted.obj : error LNK2019: unresolved external symbol _wcsicmp referenced in function LsaApLogonUserEx2
redacted.obj : error LNK2019: unresolved external symbol strlen referenced in function AnsiToUnicode
redacted.obj : error LNK2019: unresolved external symbol free referenced in function LsaApLogonUserEx2
redacted.obj : error LNK2019: unresolved external symbol mbstowcs referenced in function AnsiToUnicode
redacted.obj : error LNK2019: unresolved external symbol __stdio_common_vswprintf referenced in function _vsnwprintf_l
msvcrt.lib(dll_dllmain.obj) : error LNK2019: unresolved external symbol _initterm referenced in function "int __cdecl dllmain_crt_process_attach(struct HINSTANCE__ * const,void * const)" (?dllmain_crt_process_attach@@YAHQEAUHINSTANCE__@@QEAX@Z)
msvcrt.lib(dll_dllmain.obj) : error LNK2019: unresolved external symbol _initterm_e referenced in function "int __cdecl dllmain_crt_process_attach(struct HINSTANCE__ * const,void * const)" (?dllmain_crt_process_attach@@YAHQEAUHINSTANCE__@@QEAX@Z)
msvcrt.lib(dll_dllmain.obj) : error LNK2001: unresolved external symbol __C_specific_handler
msvcrt.lib(utility.obj) : error LNK2001: unresolved external symbol __C_specific_handler
msvcrt.lib(tncleanup.obj) : error LNK2019: unresolved external symbol __std_type_info_destroy_list referenced in function "void __cdecl __scrt_uninitialize_type_info(void)" (?__scrt_uninitialize_type_info@@YAXXZ)
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _seh_filter_dll referenced in function __scrt_dllmain_exception_filter
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _configure_narrow_argv referenced in function "public: static int __cdecl __scrt_narrow_argv_policy::configure_argv(void)" (?configure_argv@__scrt_narrow_argv_policy@@SAHXZ)
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _initialize_narrow_environment referenced in function "public: static int __cdecl __scrt_narrow_environment_policy::initialize_environment(void)" (?initialize_environment@__scrt_narrow_environment_policy@@SAHXZ)
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _initialize_onexit_table referenced in function __scrt_initialize_onexit_tables
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _register_onexit_function referenced in function _onexit
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _execute_onexit_table referenced in function __scrt_dllmain_uninitialize_c
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _crt_atexit referenced in function _onexit
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _crt_at_quick_exit referenced in function at_quick_exit
msvcrt.lib(utility.obj) : error LNK2019: unresolved external symbol _cexit referenced in function __scrt_dllmain_uninitialize_c
msvcrt.lib(utility_desktop.obj) : error LNK2019: unresolved external symbol terminate referenced in function __scrt_unhandled_exception_filter

Unused libraries:
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\odbc32.lib
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\odbccp32.lib
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\lib\x64\libcmt.lib
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\user32.lib
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\gdi32.lib
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\winspool.lib
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\comdlg32.lib
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\shell32.lib
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\ole32.lib
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\oleaut32.lib
  C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64\uuid.lib

编译器命令行选项:

/FR"x64\ReleaseU\"
/GS
/W2
/Zc:wchar_t
/Zi
/Gm-
/Od
/Fd"x64\ReleaseU\vc141.pdb"
/Zc:inline
/fp:precise
/D "WIN32"
/D "NDEBUG"
/D "_WINDOWS"
/D "_MBCS"
/D "_USRDLL"
/D "SECURITY_WIN32"
/D "REDACTED_EXPORTS"
/D "UNICODE"
/D "_BIND_TO_CURRENT_VCLIBS_VERSION=1"
/D "_VC80_UPGRADE=0x0600"
/D "_WINDLL"
/D "_UNICODE"
/errorReport:prompt
/WX
/Zc:forScope
/Gd
/MT
/FC
/Fa"x64\ReleaseU\"
/EHsc
/nologo
/Fo"x64\ReleaseU\"
/Fp"x64\ReleaseU\redacted.pch"
/diagnostics:classic 

链接器命令行选项:

/OUT:"C:\Devel\redacted\src\x64\ReleaseU\redacted.dll"
/MANIFEST
/PDB:"C:\Devel\redacted\src\pdbmap/x64/redacted.pdb"
/DYNAMICBASE:NO
"odbc32.lib" "odbccp32.lib" "netapi32.lib" "msvcrt.lib" "Ws2_32.lib" "authz.lib" "libcmt.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib"
/DEF:".\redacted.def"
/IMPLIB:"C:\Devel\redacted\src\x64\ReleaseU\redacted.lib"
/DEBUG
/DLL 
/MACHINE:X64 
/INCREMENTAL:NO 
/PGD:"C:\Devel\redacted\src\x64\ReleaseU\redacted.pgd" 
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" 
/ManifestFile:"x64\ReleaseU\redacted.dll.intermediate.manifest" 
/MAP":C:\Devel\redacted\src\pdbmap/x64/redacted.map" 
/ERRORREPORT:PROMPT 
/NOLOGO 
/VERBOSE 
/NODEFAULTLIB 
/TLBID:1 

推荐答案

原来这些函数在 Visual C++ 2015 中被移到了 vcruntime.liblibucrt.lib.

It turns out that these functions were moved in Visual C++ 2015 into vcruntime.lib and libucrt.lib.

由于这个项目有/NODEFAULTLIB,这两个库需要添加到Additional Dependencies中.

Since this project has /NODEFAULTLIB, these two libs need to be added to the Additional Dependencies.

这篇关于Visual C 运行时函数无法用 `/MT` 解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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