gpt4 book ai didi

c - 使用 `/MT` 未解析的 Visual C 运行时函数

转载 作者:太空宇宙 更新时间:2023-11-04 01:17:58 24 4
gpt4 key购买 nike

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

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

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

输出:

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 中。

由于本项目有/NODEFAULTLIB,所以需要将这两个库添加到Additional Dependencies中。

关于c - 使用 `/MT` 未解析的 Visual C 运行时函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52596313/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com