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.
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?
Output:
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
Compiler command line options:
/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
Linker command line options:
/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
It turns out that these functions were moved in Visual C++ 2015 into vcruntime.lib and libucrt.lib.
Since this project has /NODEFAULTLIB, these two libs need to be added to the Additional Dependencies.
Related
I have some simple assembly code to test my compiler and linker:
bits 64
default rel
segment .data
msg db "Hello World!", 0xd, 0xa, 0
segment .text
global main
extern ExitProcess
extern _CRT_INIT
extern printf
main:
push rbp
mov rbp, rsp
sub rsp, 32
lea rcx, [msg]
call printf
xor rax, rax
call ExitProcess
I create an object file by running:
nasm -f win64 -o .\hello_world.obj .\hello_world.asm
I then try running this command since that's what I was instructed to do in the tutorial I'm following
link .\hello_world.obj /subsystem:console /entry:main /out:hello_world_basic.exe
It doesn't work and tells me that it's missing external symbols printf and ExitProcess, so I try and include some libraries in the linking stage:
link .\hello_world.obj /subsystem:console /entry:main /out:hello_world_basic.exe kernel32.lib legacy_stdio_definitions.lib msvcrt.lib
Now it's complaining that it can't find there libraries and I'm guessing there is some LIBPATH that I must specify.
I tried to create a LIBPATH by typing this into powershell:
$env:LIB += 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\lib\x64'
It seemed to include libraries from this path when I tried linking, but kernel32.lib isn't there and legacy_stdio_definitions.lib got a bunch of linking errors itself:
PS C:\Users\cyber\Code\Assembly> link .\hello_world.obj /subsystem:console /entry:main /out:hello_world_basic.exe legacy_stdio_definitions.lib msvcrt.lib
Microsoft (R) Incremental Linker Version 14.34.31937.0
Copyright (C) Microsoft Corporation. All rights reserved.
hello_world.obj : error LNK2001: unresolved external symbol ExitProcess
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __acrt_iob_func referenced in function _vwprintf_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vfwprintf referenced in function _vfwprintf_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vfwprintf_s referenced in function _vfwprintf_s_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vfwprintf_p referenced in function _vfwprintf_p_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vfwscanf referenced in function _vfwscanf_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vswprintf referenced in function _vsnwprintf_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vswprintf_s referenced in function _vswprintf_s_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vsnwprintf_s referenced in function _vsnwprintf_s_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vswprintf_p referenced in function _vswprintf_p_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vswscanf referenced in function _vswscanf_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vfprintf referenced in function _vfprintf_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vfprintf_s referenced in function _vfprintf_s_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vfprintf_p referenced in function _vfprintf_p_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vfscanf referenced in function _vfscanf_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vsprintf referenced in function _vsnprintf_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vsprintf_s referenced in function _vsprintf_s_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vsnprintf_s referenced in function _vsnprintf_s_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vsprintf_p referenced in function _vsprintf_p_l
legacy_stdio_definitions.lib(legacy_stdio_definitions.obj) : error LNK2019: unresolved external symbol __stdio_common_vsscanf referenced in function _vsscanf_l
hello_world_basic.exe : fatal error LNK1120: 20 unresolved externals
How do I manage to link with these libraries properly and what is their path?
i'm tring to create a .dll file from this .c code (for Labview).
http://www.mathworks.com/matlabcentral/fileexchange/26190-vchoosek
But i'm not able to compile it nor with VisualStudio nor with "mcc" because both compilers return this error:
VChooseK.obj : error LNK2019: unresolved external symbol mexErrMsgIdAndTxt referenced in function BadInputTypeError
VChooseK.obj : error LNK2019: unresolved external symbol mxFree referenced in function ElemK_8Byte
VChooseK.obj : error LNK2019: unresolved external symbol mxMalloc referenced in function ElemK_8Byte
VChooseK.obj : error LNK2019: unresolved external symbol mxGetData referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetPr referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetElementSize referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mexWarnMsgIdAndTxt referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxCreateNumericMatrix_730 referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetClassID referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxSetN_730 referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxSetM_730 referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxDuplicateArray referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetScalar referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetNumberOfElements referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxIsDouble referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxIsLogical referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxIsChar referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxIsNumeric referenced in function mexFunction
Someone could help me?
I've already include the path of "mex.h" in VisualStudio
You must include the important libraries for linking. The libraries like libmex.lib;libmat.lib;libmx.lib and others if needed.
If you are using the MATLAB 2018b, the include path must include "C:\Program Files\MATLAB\R2018b\extern\include" and Library Path "C:\Program Files\MATLAB\R2018b\extern\lib\win64\microsoft".
I tried to compile main.c from this project Emacs-FullScreen-Win32 by using visual studio developer command prompt but I get the following error:
main.c
Microsoft (R) Incremental Linker Version 11.00.60610.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
main.obj
main.obj : error LNK2019: unresolved external symbol __imp__ShowWindowAsync#8 re
ferenced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__SetWindowPos#28 refe
renced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__MessageBoxW#16 refer
enced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__GetWindowLongW#8 ref
erenced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__SetWindowLongW#12 re
ferenced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__FindWindowW#8 refere
nced in function _WinMain#16
main.obj : error LNK2019: unresolved external symbol __imp__CommandLineToArgvW#8
referenced in function _is_topmost_requested
main.exe : fatal error LNK1120: 7 unresolved externals
Those unresolved external problems are likely due to you not properly linking the libraries that those functions are from. In your project settings, go to project properties. Expand configuration properties, then expand linker. In the linker's input settings, you can specify libraries that the program requires in the "additional dependencies" option.
Yesterday, I installed Visual Studio 2015 RC Community Edition. As a first test, I tried building GVim from source.
I opened a command window using "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x64 Native Tools Command Prompt.lnk", set
set include=%include%;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
so Make_mvc.mak picks up the Win32.mak file. Also, I set:
set MSVCVER=12.0
as the make file does not detect the new Visual Studio version at this point.
After this, I have:
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#\4.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\10\\include\10.0.10056.0\ucrt;C:\Program Files (x86)\Windows Kits\8.1\include\shared;C:\Program Files (x86)\Windows Kits\8.1\include\um;C:\Program Files (x86)\Windows Kits\8.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\10\\lib\10.0.10056.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\8.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\8.1\References\CommonConfiguration\Neutral;\Microsoft.VCLibs\14.0\References\CommonConfiguration\neutral;
MSVCVER=12.0
Platform=X64
PROCESSOR_ARCHITECTURE=AMD64
UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10\
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\8.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\
I am able to build a simple program:
C:\...\Temp> type t.c
#include
int main(void) {
printf("Hello %s\n", "Stackoverflow.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 Stackoverflow.com
However, when I issue the command to build my GVim (something which works fine with Visual Studio 2013 CE tools), the compilation goes fine, but I get the following link errors:
C:\...\vim\src> nmake -f Make_mvc.mak CPU=AMD64 OPTIMIZE=SPACE GETTEXT=no NETBEANS=no CSCOPE=no DIRECTX=yes GUI=yes
I am snipping most of the error messages because there are a lot of them:
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$0" (?filt$0#?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
I feel like I am missing something obvious. What changed between VS 2013 and VS 2015?
It turns out this had already been reported on vim_dev mailing list, and is due to the re-organization of the C runtime.
Specifically, the /nodefaultlib option for the linker seems to cause the problem.
The patch included in Paul Moore's follow-up worked for me.
The pre-compiled XPM library included with Vim seems to statically link to MSVCRT. This issue is mentioned in 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++.
I haven't tried to re-compile the included XPM library with VS2015, so XPM support is disabled in my GVim for now.
I'm trying to build VTK with VTK_WRAP_TCL=ON and VTK_USE_TK=ON but having following linker errors:
> Compiling...
vtkTkAppInit.cxx
Compiling resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) Microsoft Corporation. All rights reserved.
Compiling manifest to resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
Copyright (C) Microsoft Corporation. All rights reserved.
Linking...
Creating library D:\VTK\bin\bin\Debug\vtk.lib and object D:\VTK\bin\bin\Debug\vtk.exp
vtkTkAppInit.obj : error LNK2019: unresolved external symbol __imp__Tk_MainEx referenced in function _main
vtkTkAppInit.obj : error LNK2019: unresolved external symbol __imp__Tcl_CreateInterp referenced in function _main
vtkCommonTCL.lib(vtkTclUtil.obj) : error LNK2001: unresolved external symbol __imp__Tcl_CreateInterp
vtkTkAppInit.obj : error LNK2019: unresolved external symbol __imp__Tcl_SetVar referenced in function _Tcl_AppInit
vtkCommonTCL.lib(vtkTclUtil.obj) : error LNK2001: unresolved external symbol __imp__Tcl_SetVar
vtkTkAppInit.obj : error LNK2019: unresolved external symbol __imp__Tcl_Eval referenced in function _Tcl_AppInit
vtkTkAppInit.obj : error LNK2019: unresolved external symbol __imp__Tk_Init referenced in function _Tcl_AppInit
vtkTkAppInit.obj : error LNK2019: unresolved external symbol __imp__Tcl_Init referenced in function _Tcl_AppInit
vtkCommonTCL.lib(vtkTclUtil.obj) : error LNK2019: unresolved external symbol __imp__Tcl_GetAssocData referenced in function "struct vtkTclInterpStruct * __cdecl vtkGetInterpStruct(struct Tcl_Interp *)" (?vtkGetInterpStruct##YAPAUvtkTclInterpStruct##PAUTcl_Interp###Z)
vtkFilteringTCL.lib(vtkSourceTcl.obj) : error LNK2019: unresolved external symbol __imp__Tcl_DeleteCommand referenced in function "int __cdecl vtkSourceCppCommand(class vtkSource *,struct Tcl_Interp *,int,char * * const)" (?vtkSourceCppCommand##YAHPAVvtkSource##PAUTcl_Interp##HQAPAD#Z)
vtkRenderingTCL.lib(vtkAbstractVolumeMapperTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
vtkRenderingTCL.lib(vtkImporterTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
vtkWidgetsTCL.lib(vtkContinuousValueWidgetRepresentationTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
vtkFilteringTCL.lib(vtkProcessObjectTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
vtkFilteringTCL.lib(vtkMapper2DTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
vtkFilteringTCL.lib(vtkViewportTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
vtkFilteringTCL.lib(vtkAbstractMapperTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
vtkFilteringTCL.lib(vtkThreadedImageAlgorithmTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
vtkFilteringTCL.lib(vtkImageInPlaceFilterTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
vtkFilteringTCL.lib(vtkRectilinearGridSourceTcl.obj) : error LNK2001: unresolved external symbol __imp__Tcl_DeleteCommand
.
.
D:\VTK\bin\bin\Debug\vtk.exe : fatal error LNK1120: 65 unresolved externals
Results
Build log was saved at "file://d:\VTK\bin\Wrapping\Tcl\vtk.dir\Debug\BuildLog.htm"
vtk - 22432 error(s), 0 warning(s)
Please help to solve.
Thanks.
I installed Tclx64 version and was trying to build it with 32 bit compiler.
Problem is solved by installing x86 version and compiled it with Debug|Win32.
http://public.kitware.com/pipermail/vtkusers/2011-September/118696.html this post helped me to understand the problem.