为什么我无法使用 Visual Studio 2015 RC 命令行工具构建 Vim?
Why am I not able to build Vim with Visual Studio 2015 RC command line tools?
昨天,我安装了 Visual Studio 2015 RC Community Edition。作为第一个测试,我尝试从源代码构建 GVim。
我使用 "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x64 Native Tools Command Prompt.lnk"
打开命令 window,设置
set include=%include%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
所以 Make_mvc.mak
选择 Win32.mak
文件。另外,我设置:
set MSVCVER=12.0
因为 make file 此时没有检测到新的 Visual Studio 版本。
在此之后,我有:
Framework40Version=v4.0
FrameworkDir=C:\Windows\Microsoft.NET\Framework64
FrameworkDIR64=C:\Windows\Microsoft.NET\Framework64
FrameworkVersion=v4.0.30319
FrameworkVersion64=v4.0.30319
FSHARPINSTALLDIR=C:\Program Files (x86)\Microsoft SDKs\F#.0\Framework\v4.0\
INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\include.0.10056.0\ucrt;C:\Program Files (x86)\Windows Kits.1\include\shared;C:\Program Files (x86)\Windows Kits.1\include\um;C:\Program Files (x86)\Windows Kits.1\include\winrt;;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Windows Kits\lib.0.10056.0\ucrt\x64;C:\Program Files (x86)\Windows Kits.1\lib\winv6.3\um\x64;
LIBPATH=C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Windows Kits.1\References\CommonConfiguration\Neutral;\Microsoft.VCLibs.0\References\CommonConfiguration\neutral;
MSVCVER=12.0
Platform=X64
PROCESSOR_ARCHITECTURE=AMD64
UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\
VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\
VisualStudioVersion=14.0
VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 14.0\
windir=C:\Windows
WindowsSdkDir=C:\Program Files (x86)\Windows Kits.1\
WindowsSDK_ExecutablePath_x64=C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\
WindowsSDK_ExecutablePath_x86=C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\
我能够构建一个简单的程序:
C:\...\Temp> type t.c
#include
int main(void) {
printf("Hello %s\n", "whosebug.com");
return 0;
}
C:\...\Temp> cl t.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.22816 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
t.c
Microsoft (R) Incremental Linker Version 14.00.22816.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:t.exe
t.obj
C:\...\Temp> t.exe
Hello whosebug.com
然而,当我发出构建我的 GVim 的命令时(可以与 Visual Studio 2013 CE 工具一起正常工作的东西),编译正常,但我得到以下 link 错误:
C:\...\vim\src> nmake -f Make_mvc.mak CPU=AMD64 OPTIMIZE=SPACE GETTEXT=no NETBEANS=no CSCOPE=no DIRECTX=yes GUI=yes
我删掉了大部分错误消息,因为错误消息很多:
gui_dwrite.obj : error LNK2001: unresolved external symbol memcmp
blowfish.obj : error LNK2001: unresolved external symbol memcmp
crypt.obj : error LNK2001: unresolved external symbol memcmp
sha256.obj : error LNK2001: unresolved external symbol memcmp
undo.obj : error LNK2001: unresolved external symbol memcmp
blowfish.obj : error LNK2019: unresolved external symbol memcpy referenced in function bf_e_cblock
winclip.obj : error LNK2001: unresolved external symbol memcpy
screen.obj : error LNK2001: unresolved external symbol memcpy
sha256.obj : error LNK2001: unresolved external symbol memcpy
gui.obj : error LNK2001: unresolved external symbol memmove
gui_w32.obj : error LNK2001: unresolved external symbol memmove
tag.obj : error LNK2001: unresolved external symbol memmove
term.obj : error LNK2001: unresolved external symbol memmove
ui.obj : error LNK2001: unresolved external symbol memmove
undo.obj : error LNK2001: unresolved external symbol memmove
screen.obj : error LNK2001: unresolved external symbol memmove
search.obj : error LNK2001: unresolved external symbol memmove
spell.obj : error LNK2001: unresolved external symbol memmove
syntax.obj : error LNK2001: unresolved external symbol memmove
os_mswin.obj : error LNK2001: unresolved external symbol memmove
os_win32.obj : error LNK2001: unresolved external symbol memmove
quickfix.obj : error LNK2001: unresolved external symbol memmove
regexp.obj : error LNK2001: unresolved external symbol memmove
misc2.obj : error LNK2001: unresolved external symbol memmove
normal.obj : error LNK2001: unresolved external symbol memmove
ops.obj : error LNK2001: unresolved external symbol memmove
option.obj : error LNK2001: unresolved external symbol memmove
memline.obj : error LNK2001: unresolved external symbol memmove
menu.obj : error LNK2001: unresolved external symbol memmove
message.obj : error LNK2001: unresolved external symbol memmove
misc1.obj : error LNK2001: unresolved external symbol memmove
getchar.obj : error LNK2001: unresolved external symbol memmove
hashtab.obj : error LNK2001: unresolved external symbol memmove
mark.obj : error LNK2001: unresolved external symbol memmove
...
misc2.obj : error LNK2001: unresolved external symbol fwrite
spell.obj : error LNK2001: unresolved external symbol fwrite
edit.obj : error LNK2019: unresolved external symbol isalnum referenced in function ins_ctrl_ey
regexp.obj : error LNK2001: unresolved external symbol isalnum
ui.obj : error LNK2001: unresolved external symbol strncpy
gui_w32.obj : error LNK2001: unresolved external symbol strncpy
libXpm.lib(parse.obj) : error LNK2001: unresolved external symbol strncpy
libXpm.lib(data.obj) : error LNK2001: unresolved external symbol strncpy
regexp.obj : error LNK2001: unresolved external symbol strncpy
screen.obj : error LNK2001: unresolved external symbol strncpy
...
main.obj : error LNK2001: unresolved external symbol close
memfile.obj : error LNK2001: unresolved external symbol close
libXpm.lib(parse.obj) : error LNK2001: unresolved external symbol free
libXpm.lib(hashtab.obj) : error LNK2001: unresolved external symbol free
libXpm.lib(data.obj) : error LNK2001: unresolved external symbol free
libXpm.lib(misc.obj) : error LNK2001: unresolved external symbol free
...
eval.obj : error LNK2001: unresolved external symbol free
misc2.obj : error LNK2001: unresolved external symbol free
os_win32.obj : error LNK2001: unresolved external symbol free
gui_w32.obj : error LNK2001: unresolved external symbol free
libcmt.lib(new_scalar.obj) : error LNK2001: unresolved external symbol malloc
libXpm.lib(simx.obj) : error LNK2001: unresolved external symbol malloc
eval.obj : error LNK2001: unresolved external symbol malloc
misc2.obj : error LNK2001: unresolved external symbol malloc
os_win32.obj : error LNK2001: unresolved external symbol malloc
gui_w32.obj : error LNK2001: unresolved external symbol malloc
normal.obj : error LNK2001: unresolved external symbol realloc
regexp.obj : error LNK2001: unresolved external symbol realloc
libXpm.lib(simx.obj) : error LNK2001: unresolved external symbol realloc
eval.obj : error LNK2001: unresolved external symbol realloc
memline.obj : error LNK2001: unresolved external symbol realloc
misc1.obj : error LNK2001: unresolved external symbol realloc
misc2.obj : error LNK2001: unresolved external symbol realloc
...
ex_docmd.obj : error LNK2001: unresolved external symbol stricmp
ops.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
option.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
search.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
spell.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
fold.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
getchar.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
main.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
mark.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
eval.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
ex_cmds.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
ex_docmd.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
ex_getln.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf
window.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
gui.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
gui_w32.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
version.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
spell.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
syntax.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
tag.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
term.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
regexp.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
screen.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
search.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
sha256.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
ops.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
option.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf
...
_crt_atexit referenced in function _onexit
libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol _crt_at_quick_exit referenced in function at_quick_exit
libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol _cexit referenced in function __scrt_dllmain_uninitialize_c
libcmt.lib(exe_winmain.obj) : error LNK2001: unresolved external symbol _cexit
libcmt.lib(new_scalar.obj) : error LNK2019: unresolved external symbol _callnewh referenced in function "void * __cdecl operator new(unsigned __int64)" (??2@YAPEAX_K@Z)
libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _seh_filter_exe referenced in function "int `int __cdecl __scrt_common_main_seh(void)'::`1'::filt[=20=]" (?filt[=20=]@?0??__scrt_common_main_seh@@YAHXZ@4HA)
libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _set_app_type referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ)
libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __setusermatherr referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ)
libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _configure_narrow_argv referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ)
libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _get_narrow_winmain_command_line referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _initterm referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
...
libXpm.lib(rgb.obj) : error LNK2019: unresolved external symbol strdup referenced in function xpmGetRGBfromName
oldnames.lib(strdup.obj) : error LNK2001: unresolved external symbol strdup
oldnames.lib(strdup.obj) : error LNK2001: unresolved external symbol _strdup
gvim.exe : fatal error LNK1120: 183 unresolved externals
我觉得我遗漏了一些明显的东西。 VS 2013 和 VS 2015 之间有什么变化?
事实证明,这已经在 vim_dev mailing list 上报告过,并且是由于 C 运行时的重新组织。
具体来说,linker 的 /nodefaultlib
选项似乎导致了问题。
patch included in Paul Moore's follow-up 对我有用。
Vim 中包含的预编译 XPM 库似乎静态 link 到 MSVCRT。 CRT Library Features:
中提到了这个问题
If you have more than one DLL or EXE, then you may have more than one CRT, whether or not you are using different versions of Visual C++. For example, statically linking the CRT into multiple DLLs can present the same problem. Developers encountering this problem with static CRTs have been instructed to compile with /MD
to use the CRT DLL. Now that the CRT DLL has been renamed to msvcr110.dll
, applications may have some components linked to msvcrt.dll
and others to msvcr110.dll
. If your DLLs pass CRT resources across the msvcrt.dll
and msvcr110.dll
boundary, you will encounter issues with mismatched CRTs and need to recompile your project with Visual C++.
我还没有尝试用 VS2015 重新编译包含的 XPM 库,所以我的 GVim 暂时禁用了 XPM 支持。
昨天,我安装了 Visual Studio 2015 RC Community Edition。作为第一个测试,我尝试从源代码构建 GVim。
我使用 "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x64 Native Tools Command Prompt.lnk"
打开命令 window,设置
set include=%include%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
所以 Make_mvc.mak
选择 Win32.mak
文件。另外,我设置:
set MSVCVER=12.0
因为 make file 此时没有检测到新的 Visual Studio 版本。
在此之后,我有:
Framework40Version=v4.0 FrameworkDir=C:\Windows\Microsoft.NET\Framework64 FrameworkDIR64=C:\Windows\Microsoft.NET\Framework64 FrameworkVersion=v4.0.30319 FrameworkVersion64=v4.0.30319 FSHARPINSTALLDIR=C:\Program Files (x86)\Microsoft SDKs\F#.0\Framework\v4.0\ INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\include.0.10056.0\ucrt;C:\Program Files (x86)\Windows Kits.1\include\shared;C:\Program Files (x86)\Windows Kits.1\include\um;C:\Program Files (x86)\Windows Kits.1\include\winrt;;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Windows Kits\lib.0.10056.0\ucrt\x64;C:\Program Files (x86)\Windows Kits.1\lib\winv6.3\um\x64; LIBPATH=C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Windows Kits.1\References\CommonConfiguration\Neutral;\Microsoft.VCLibs.0\References\CommonConfiguration\neutral; MSVCVER=12.0 Platform=X64 PROCESSOR_ARCHITECTURE=AMD64 UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\ VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ VisualStudioVersion=14.0 VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\ VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\ VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\ VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\ VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 14.0\ windir=C:\Windows WindowsSdkDir=C:\Program Files (x86)\Windows Kits.1\ WindowsSDK_ExecutablePath_x64=C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\ WindowsSDK_ExecutablePath_x86=C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\
我能够构建一个简单的程序:
C:\...\Temp> type t.c #include int main(void) { printf("Hello %s\n", "whosebug.com"); return 0; } C:\...\Temp> cl t.c Microsoft (R) C/C++ Optimizing Compiler Version 19.00.22816 for x64 Copyright (C) Microsoft Corporation. All rights reserved. t.c Microsoft (R) Incremental Linker Version 14.00.22816.0 Copyright (C) Microsoft Corporation. All rights reserved. /out:t.exe t.obj C:\...\Temp> t.exe Hello whosebug.com
然而,当我发出构建我的 GVim 的命令时(可以与 Visual Studio 2013 CE 工具一起正常工作的东西),编译正常,但我得到以下 link 错误:
C:\...\vim\src> nmake -f Make_mvc.mak CPU=AMD64 OPTIMIZE=SPACE GETTEXT=no NETBEANS=no CSCOPE=no DIRECTX=yes GUI=yes
我删掉了大部分错误消息,因为错误消息很多:
gui_dwrite.obj : error LNK2001: unresolved external symbol memcmp blowfish.obj : error LNK2001: unresolved external symbol memcmp crypt.obj : error LNK2001: unresolved external symbol memcmp sha256.obj : error LNK2001: unresolved external symbol memcmp undo.obj : error LNK2001: unresolved external symbol memcmp blowfish.obj : error LNK2019: unresolved external symbol memcpy referenced in function bf_e_cblock winclip.obj : error LNK2001: unresolved external symbol memcpy screen.obj : error LNK2001: unresolved external symbol memcpy sha256.obj : error LNK2001: unresolved external symbol memcpy gui.obj : error LNK2001: unresolved external symbol memmove gui_w32.obj : error LNK2001: unresolved external symbol memmove tag.obj : error LNK2001: unresolved external symbol memmove term.obj : error LNK2001: unresolved external symbol memmove ui.obj : error LNK2001: unresolved external symbol memmove undo.obj : error LNK2001: unresolved external symbol memmove screen.obj : error LNK2001: unresolved external symbol memmove search.obj : error LNK2001: unresolved external symbol memmove spell.obj : error LNK2001: unresolved external symbol memmove syntax.obj : error LNK2001: unresolved external symbol memmove os_mswin.obj : error LNK2001: unresolved external symbol memmove os_win32.obj : error LNK2001: unresolved external symbol memmove quickfix.obj : error LNK2001: unresolved external symbol memmove regexp.obj : error LNK2001: unresolved external symbol memmove misc2.obj : error LNK2001: unresolved external symbol memmove normal.obj : error LNK2001: unresolved external symbol memmove ops.obj : error LNK2001: unresolved external symbol memmove option.obj : error LNK2001: unresolved external symbol memmove memline.obj : error LNK2001: unresolved external symbol memmove menu.obj : error LNK2001: unresolved external symbol memmove message.obj : error LNK2001: unresolved external symbol memmove misc1.obj : error LNK2001: unresolved external symbol memmove getchar.obj : error LNK2001: unresolved external symbol memmove hashtab.obj : error LNK2001: unresolved external symbol memmove mark.obj : error LNK2001: unresolved external symbol memmove ... misc2.obj : error LNK2001: unresolved external symbol fwrite spell.obj : error LNK2001: unresolved external symbol fwrite edit.obj : error LNK2019: unresolved external symbol isalnum referenced in function ins_ctrl_ey regexp.obj : error LNK2001: unresolved external symbol isalnum ui.obj : error LNK2001: unresolved external symbol strncpy gui_w32.obj : error LNK2001: unresolved external symbol strncpy libXpm.lib(parse.obj) : error LNK2001: unresolved external symbol strncpy libXpm.lib(data.obj) : error LNK2001: unresolved external symbol strncpy regexp.obj : error LNK2001: unresolved external symbol strncpy screen.obj : error LNK2001: unresolved external symbol strncpy ... main.obj : error LNK2001: unresolved external symbol close memfile.obj : error LNK2001: unresolved external symbol close libXpm.lib(parse.obj) : error LNK2001: unresolved external symbol free libXpm.lib(hashtab.obj) : error LNK2001: unresolved external symbol free libXpm.lib(data.obj) : error LNK2001: unresolved external symbol free libXpm.lib(misc.obj) : error LNK2001: unresolved external symbol free ... eval.obj : error LNK2001: unresolved external symbol free misc2.obj : error LNK2001: unresolved external symbol free os_win32.obj : error LNK2001: unresolved external symbol free gui_w32.obj : error LNK2001: unresolved external symbol free libcmt.lib(new_scalar.obj) : error LNK2001: unresolved external symbol malloc libXpm.lib(simx.obj) : error LNK2001: unresolved external symbol malloc eval.obj : error LNK2001: unresolved external symbol malloc misc2.obj : error LNK2001: unresolved external symbol malloc os_win32.obj : error LNK2001: unresolved external symbol malloc gui_w32.obj : error LNK2001: unresolved external symbol malloc normal.obj : error LNK2001: unresolved external symbol realloc regexp.obj : error LNK2001: unresolved external symbol realloc libXpm.lib(simx.obj) : error LNK2001: unresolved external symbol realloc eval.obj : error LNK2001: unresolved external symbol realloc memline.obj : error LNK2001: unresolved external symbol realloc misc1.obj : error LNK2001: unresolved external symbol realloc misc2.obj : error LNK2001: unresolved external symbol realloc ... ex_docmd.obj : error LNK2001: unresolved external symbol stricmp ops.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf option.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf search.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf spell.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf fold.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf getchar.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf main.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf mark.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf eval.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf ex_cmds.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf ex_docmd.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf ex_getln.obj : error LNK2001: unresolved external symbol __stdio_common_vfprintf window.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf gui.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf gui_w32.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf version.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf spell.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf syntax.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf tag.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf term.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf regexp.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf screen.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf search.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf sha256.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf ops.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf option.obj : error LNK2001: unresolved external symbol __stdio_common_vsprintf ... _crt_atexit referenced in function _onexit libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol _crt_at_quick_exit referenced in function at_quick_exit libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol _cexit referenced in function __scrt_dllmain_uninitialize_c libcmt.lib(exe_winmain.obj) : error LNK2001: unresolved external symbol _cexit libcmt.lib(new_scalar.obj) : error LNK2019: unresolved external symbol _callnewh referenced in function "void * __cdecl operator new(unsigned __int64)" (??2@YAPEAX_K@Z) libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _seh_filter_exe referenced in function "int `int __cdecl __scrt_common_main_seh(void)'::`1'::filt[=20=]" (?filt[=20=]@?0??__scrt_common_main_seh@@YAHXZ@4HA) libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _set_app_type referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ) libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __setusermatherr referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ) libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _configure_narrow_argv referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ) libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _get_narrow_winmain_command_line referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ) libcmt.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _initterm referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ) ... libXpm.lib(rgb.obj) : error LNK2019: unresolved external symbol strdup referenced in function xpmGetRGBfromName oldnames.lib(strdup.obj) : error LNK2001: unresolved external symbol strdup oldnames.lib(strdup.obj) : error LNK2001: unresolved external symbol _strdup gvim.exe : fatal error LNK1120: 183 unresolved externals
我觉得我遗漏了一些明显的东西。 VS 2013 和 VS 2015 之间有什么变化?
事实证明,这已经在 vim_dev mailing list 上报告过,并且是由于 C 运行时的重新组织。
具体来说,linker 的 /nodefaultlib
选项似乎导致了问题。
patch included in Paul Moore's follow-up 对我有用。
Vim 中包含的预编译 XPM 库似乎静态 link 到 MSVCRT。 CRT Library Features:
中提到了这个问题If you have more than one DLL or EXE, then you may have more than one CRT, whether or not you are using different versions of Visual C++. For example, statically linking the CRT into multiple DLLs can present the same problem. Developers encountering this problem with static CRTs have been instructed to compile with
/MD
to use the CRT DLL. Now that the CRT DLL has been renamed tomsvcr110.dll
, applications may have some components linked tomsvcrt.dll
and others tomsvcr110.dll
. If your DLLs pass CRT resources across themsvcrt.dll
andmsvcr110.dll
boundary, you will encounter issues with mismatched CRTs and need to recompile your project with Visual C++.
我还没有尝试用 VS2015 重新编译包含的 XPM 库,所以我的 GVim 暂时禁用了 XPM 支持。