visual-studiolinker

Compiling emWin simulation on newer Visual Studio


I've downloaded Segger simulation of emWin but it won't compile on my Visual Studio 2015 Express. The following linker problems occurred:

1>libcmtd.lib(_init_.obj) : error LNK2019: unresolved external symbol __CrtDbgReport referenced in function __CRT_RTC_INIT
1>libcmtd.lib(_init_.obj) : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function __CRT_RTC_INITW
1>libcmtd.lib(_error_.obj) : error LNK2019: unresolved external symbol ___stdio_common_vsprintf_s referenced in function __vsprintf_s_l
1>libcmtd.lib(_error_.obj) : error LNK2019: unresolved external symbol __except_handler4 referenced in function "int __cdecl DebuggerProbe(unsigned long)" (?DebuggerProbe@@YAHK@Z)
1>libcmtd.lib(exe_winmain.obj) : error LNK2001: unresolved external symbol __except_handler4
1>libcmtd.lib(utility.obj) : error LNK2001: unresolved external symbol __except_handler4
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __seh_filter_exe referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
1>libcmtd.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)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol ___setusermatherr referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ)
1>libcmtd.lib(exe_winmain.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)
1>libcmtd.lib(utility.obj) : error LNK2001: unresolved external symbol __configure_narrow_argv
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __initialize_narrow_environment referenced in function "void __cdecl initialize_environment(void)" (?initialize_environment@@YAXXZ)
1>libcmtd.lib(utility.obj) : error LNK2001: unresolved external symbol __initialize_narrow_environment
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __get_narrow_winmain_command_line referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>libcmtd.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)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __initterm_e referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _exit referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __exit referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __set_fmode referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __cexit referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
1>libcmtd.lib(utility.obj) : error LNK2001: unresolved external symbol __cexit
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __c_exit referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __register_thread_local_exe_atexit_callback referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __configthreadlocale referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol __set_new_mode referenced in function "void __cdecl pre_cpp_initialization(void)" (?pre_cpp_initialization@@YAXXZ)
1>libcmtd.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol ___p__commode referenced in function "int __cdecl pre_c_initialization(void)" (?pre_c_initialization@@YAHXZ)
1>libcmtd.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __wmakepath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z)
1>libcmtd.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol __wsplitpath_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z)
1>libcmtd.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol _wcscpy_s referenced in function "int __cdecl GetPdbDllPathFromFilePath(wchar_t const *,wchar_t *,unsigned int)" (?GetPdbDllPathFromFilePath@@YAHPB_WPA_WI@Z)
1>libcmtd.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol ___vcrt_GetModuleFileNameW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ)
1>libcmtd.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol ___vcrt_GetModuleHandleW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ)
1>libcmtd.lib(_pdblkup_.obj) : error LNK2019: unresolved external symbol ___vcrt_LoadLibraryExW referenced in function "struct HINSTANCE__ * __cdecl GetPdbDll(void)" (?GetPdbDll@@YAPAUHINSTANCE__@@XZ)
1>libcmtd.lib(utility.obj) : error LNK2019: unresolved external symbol __seh_filter_dll referenced in function ___scrt_dllmain_exception_filter
1>libcmtd.lib(utility.obj) : error LNK2019: unresolved external symbol __initialize_onexit_table referenced in function ___scrt_initialize_onexit_tables
1>libcmtd.lib(utility.obj) : error LNK2019: unresolved external symbol __register_onexit_function referenced in function __onexit
1>libcmtd.lib(utility.obj) : error LNK2019: unresolved external symbol __execute_onexit_table referenced in function ___scrt_dllmain_uninitialize_c
1>libcmtd.lib(utility.obj) : error LNK2019: unresolved external symbol __crt_atexit referenced in function __onexit
1>libcmtd.lib(utility.obj) : error LNK2019: unresolved external symbol __crt_at_quick_exit referenced in function _at_quick_exit
1>libcmtd.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)
1>libcmtd.lib(default_precision.obj) : error LNK2019: unresolved external symbol __controlfp_s referenced in function __initialize_default_precision
1>libcmtd.lib(utility_desktop.obj) : error LNK2019: unresolved external symbol _terminate referenced in function ___scrt_unhandled_exception_filter@4
1>libcmtd.lib(utility_desktop.obj) : error LNK2019: unresolved external symbol _memset referenced in function ___scrt_fastfail
1>GUI.lib(GUIDRV_Win32.OBJ) : error LNK2001: unresolved external symbol _memset
1>GUI.lib(GUIDEV_UsageBM.OBJ) : error LNK2001: unresolved external symbol _memset
1>GUI.lib(WM_Motion.OBJ) : error LNK2019: unresolved external symbol _abs referenced in function __ExecMotion
1>GUI.lib(SWIPELIST.OBJ) : error LNK2019: unresolved external symbol _strlen referenced in function _SWIPELIST__CalcItemSize
1>GUI.lib(GUI_ErrorOut.OBJ) : error LNK2001: unresolved external symbol _strlen
1>GUI.lib(GUI_Warn.OBJ) : error LNK2001: unresolved external symbol _strlen
1>GUI.lib(GUIDEV_32.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(GUI_Realloc.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(GUI_ALLOC_AllocInit.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(GUI_ARRAY.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(WM_UserData.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(GUIDEV_8.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(GUIDEV_16.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(SWIPELIST.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(GUI_Alloc.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(GUI_SetAlpha.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(GUIDEV_StaticDevices.OBJ) : error LNK2001: unresolved external symbol _memcpy
1>GUI.lib(GUI_Alloc.OBJ) : error LNK2019: unresolved external symbol _memmove referenced in function __RemoveHoles
1>GUISim.lib(SIM_GetRegions.OBJ) : error LNK2001: unresolved external symbol _memmove
1>GUISim.lib(SIM_GUI.OBJ) : error LNK2019: unresolved external symbol __imp__timeGetTime@0 referenced in function _SIM_GUI_Init
1>GUISim.lib(SIM_GUI_App.OBJ) : error LNK2019: unresolved external symbol __ftol referenced in function __AdjustXPos@8
1>GUISim.lib(SIM_GUI_App.OBJ) : error LNK2019: unresolved external symbol _sprintf referenced in function __WndProcSysInfo@16
1>GUISim.lib(LCDSIM.OBJ) : error LNK2001: unresolved external symbol _sprintf
1>GUISim.lib(SIM_GUI_Log.OBJ) : error LNK2001: unresolved external symbol _sprintf
1>GUISim.lib(SIM_GetRegions.OBJ) : error LNK2019: unresolved external symbol _free referenced in function __AddRegion
1>GUISim.lib(SIM_GetRegions.OBJ) : error LNK2019: unresolved external symbol _calloc referenced in function __AddRegion
1>GUI.lib(GUI_MOUSE.OBJ) : error LNK2019: unresolved external symbol _memcmp referenced in function _GUI_MOUSE_StoreState
1>GUI.lib(GUI_TOUCH.OBJ) : error LNK2001: unresolved external symbol _memcmp

As Visual Studio had to "Retarget the solution", I wanted to know what has to be done as it converted the project (wrongly) from Visual Studio C++ v6.0 (quite old).


Solution

  • After contacting Segger support, they told me that on v5.40 they included a HowTo about updating the project to MSVC 2015 / 2017:

    Make sure the selected Windows SDK is installed:
    Properties -> Configuration Properties -> General -> Windows SDK Version.
    
    1. Right-Click on the Project (e.g. SimulationTrial) -> Properties
    2  Set Configuration to "All Configurations"
    3. Goto Configuration Properties -> Linker -> Input.
    4. Add under Additional Dependencies: "legacy_stdio_definitions.lib"
    5. Set Ignore All Default Libraries: "No"
    6. Set Ignore Specific Default Libraries: "LIBC.lib;LIBCMTD.lib"
    7. Goto Configuration Properties -> Linker -> Advanced
    8. Set Image Has Safe Exception Handlers:"No (/SAFESEH:NO)"
    9. Click "OK"-Button.
    

    It worked for me as expected!