ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
60.84k stars 10.28k forks source link

Linker issues when installing Dear ImGui using vcpkg #6285

Closed MacQuant closed 1 year ago

MacQuant commented 1 year ago

I have installed Dear ImGui using vcpkg by running the below command:

vcpkg install imgui[core,dx12-binding,win32-binding]:x64-windows

However I am getting the below many link errors that I don’t understand when building this:

#include <imgui.h>
int main(int argc, char* argv[])
{
    IMGUI_CHECKVERSION();
}

Errors:

1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4217: symbol 'strncmp' defined in 'libucrtd.lib(strncmp.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"void __cdecl ImGui::DockSettingsHandler_ReadLine(struct ImGuiContext *,struct ImGuiSettingsHandler *,void *,char const *)" (?DockSettingsHandler_ReadLine@ImGui@@YAXPEAUImGuiContext@@PEAUImGuiSettingsHandler@@PEAXPEBD@Z)'
1>LINK : warning LNK4286: symbol 'strncmp' defined in 'libucrtd.lib(strncmp.obj)' is imported by 'imguid.lib(imgui_widgets.cpp.obj)'
1>LINK : warning LNK4217: symbol 'strncpy' defined in 'libucrtd.lib(strncpy.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"void __cdecl ImStrncpy(char *,char const *,unsigned __int64)" (?ImStrncpy@@YAXPEADPEBD_K@Z)'
1>LINK : warning LNK4217: symbol '_wassert' defined in 'libucrtd.lib(assert.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"struct ImGuiIO & __cdecl ImGui::GetIO(void)" (?GetIO@ImGui@@YAAEAUImGuiIO@@xz)'
1>LINK : warning LNK4286: symbol '_wassert' defined in 'libucrtd.lib(assert.obj)' is imported by 'imguid.lib(imgui_draw.cpp.obj)'
1>LINK : warning LNK4286: symbol '_wassert' defined in 'libucrtd.lib(assert.obj)' is imported by 'imguid.lib(imgui_widgets.cpp.obj)'
1>LINK : warning LNK4286: symbol '_wassert' defined in 'libucrtd.lib(assert.obj)' is imported by 'imguid.lib(imgui_tables.cpp.obj)'
1>LINK : warning LNK4217: symbol '__acrt_iob_func' defined in 'libucrtd.lib(_file.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"void __cdecl ImGui::LogToTTY(int)" (?LogToTTY@ImGui@@Yaxh@Z)'
1>LINK : warning LNK4217: symbol 'fclose' defined in 'libucrtd.lib(fclose.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"bool __cdecl ImFileClose(struct _iobuf *)" (?ImFileClose@@YA_NPEAU_iobuf@@@z)'
1>LINK : warning LNK4217: symbol 'fflush' defined in 'libucrtd.lib(fflush.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"void __cdecl ImGui::LogFinish(void)" (?LogFinish@ImGui@@YAXXZ)'
1>LINK : warning LNK4217: symbol 'fwrite' defined in 'libucrtd.lib(fwrite.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"unsigned __int64 __cdecl ImFileWrite(void const *,unsigned __int64,unsigned __int64,struct _iobuf *)" (?ImFileWrite@@YA_KPEBX_K1PEAU_iobuf@@@z)'
1>LINK : warning LNK4217: symbol '__stdio_common_vfprintf' defined in 'libucrtd.lib(output.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '_vfprintf_l'
1>LINK : warning LNK4217: symbol '__stdio_common_vsprintf' defined in 'libucrtd.lib(output.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '_vsnprintf_l'
1>LINK : warning LNK4217: symbol 'free' defined in 'libucrtd.lib(free.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"void __cdecl ImGui::UpdateViewportPlatformMonitor(struct ImGuiViewportP *)" (?UpdateViewportPlatformMonitor@ImGui@@YAXPEAUImGuiViewportP@@@z)'
1>LINK : warning LNK4217: symbol 'malloc' defined in 'libucrtd.lib(malloc.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"void __cdecl ImGui::UpdateViewportPlatformMonitor(struct ImGuiViewportP *)" (?UpdateViewportPlatformMonitor@ImGui@@YAXPEAUImGuiViewportP@@@z)'
1>LINK : warning LNK4217: symbol 'qsort' defined in 'libucrtd.lib(qsort.obj)' is imported by 'imguid.lib(imgui.cpp.obj)' in function '"void __cdecl ImQsort(void ,unsigned __int64,unsigned __int64,int (__cdecl)(void const *,void const *))" (?ImQsort@@YAXPEAX_K1P6AHPEBX2@Z@Z)'
1>LINK : warning LNK4286: symbol 'qsort' defined in 'libucrtd.lib(qsort.obj)' is imported by 'imguid.lib(imgui_draw.cpp.obj)'
1>LINK : warning LNK4217: symbol 'qsort' defined in 'libucrtd.lib(qsort.obj)' is imported by 'imguid.lib(imgui_widgets.cpp.obj)' in function '"float __cdecl ImGui::RoundScalarWithFormatT(char const *,int,float)" (??$RoundScalarWithFormatT@M@ImGui@@YAMPEBDHM@Z)'
1>LINK : warning LNK4217: symbol 'ceilf' defined in 'libucrtd.lib(ceilf.obj)' is imported by 'imguid.lib(imgui_draw.cpp.obj)' in function '"public: void __cdecl ImDrawList::PathArcTo(struct ImVec2 const &,float,float,float,int)" (?PathArcTo@ImDrawList@@QEAAXAEBUImVec2@@mmmh@Z)'
1>imguid.lib(imgui.cpp.obj) : error LNK2019: unresolved external symbol __imp__wfopen referenced in function "struct _iobuf * __cdecl ImFileOpen(char const *,char const *)" (?ImFileOpen@@YAPEAU_iobuf@@PEBD0@Z)
1>imguid.lib(imgui.cpp.obj) : error LNK2019: unresolved external symbol __imp_fread referenced in function "unsigned __int64 __cdecl ImFileRead(void *,unsigned __int64,unsigned __int64,struct _iobuf *)" (?ImFileRead@@YA_KPEAX_K1PEAU_iobuf@@@z)
1>imguid.lib(imgui.cpp.obj) : error LNK2019: unresolved external symbol __imp_fseek referenced in function "unsigned __int64 __cdecl ImFileGetSize(struct _iobuf *)" (?ImFileGetSize@@YA_KPEAU_iobuf@@@z)
1>imguid.lib(imgui.cpp.obj) : error LNK2019: unresolved external symbol __imp_ftell referenced in function "unsigned __int64 __cdecl ImFileGetSize(struct _iobuf *)" (?ImFileGetSize@@YA_KPEAU_iobuf@@@z)
1>imguid.lib(imgui.cpp.obj) : error LNK2019: unresolved external symbol __imp___stdio_common_vsscanf referenced in function _vsscanf_l
1>imguid.lib(imgui_widgets.cpp.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsscanf
1>imguid.lib(imgui_tables.cpp.obj) : error LNK2001: unresolved external symbol __imp___stdio_common_vsscanf
1>imguid.lib(imgui.cpp.obj) : error LNK2019: unresolved external symbol __imp_fmodf referenced in function "void __cdecl ImGui::ShowStackToolWindow(bool *)" (?ShowStackToolWindow@ImGui@@YAXPEA_N@Z)
1>imguid.lib(imgui_widgets.cpp.obj) : error LNK2001: unresolved external symbol __imp_fmodf
1>imguid.lib(imgui.cpp.obj) : error LNK2019: unresolved external symbol __imp_sqrtf referenced in function "void __cdecl ImGui::DebugNodeFont(struct ImFont *)" (?DebugNodeFont@ImGui@@YAXPEAUImFont@@@z)
1>imguid.lib(imgui_draw.cpp.obj) : error LNK2001: unresolved external symbol __imp_sqrtf
1>imguid.lib(imgui.cpp.obj) : error LNK2019: unresolved external symbol __imp_toupper referenced in function "int __cdecl ImStricmp(char const *,char const *)" (?ImStricmp@@YAHPEBD0@Z)
1>imguid.lib(imgui_draw.cpp.obj) : error LNK2019: unresolved external symbol __imp_acosf referenced in function "public: int __cdecl ImDrawList::_CalcCircleAutoSegmentCount(float)const " (?_CalcCircleAutoSegmentCount@ImDrawList@@QEBAHM@Z)
1>imguid.lib(imgui_draw.cpp.obj) : error LNK2019: unresolved external symbol __imp_cosf referenced in function "public: void __cdecl ImDrawList::PathArcTo(struct ImVec2 const &,float,float,float,int)" (?PathArcTo@ImDrawList@@QEAAXAEBUImVec2@@mmmh@Z)
1>imguid.lib(imgui_widgets.cpp.obj) : error LNK2001: unresolved external symbol __imp_cosf
1>imguid.lib(imgui_draw.cpp.obj) : error LNK2019: unresolved external symbol __imp_sinf referenced in function "public: void __cdecl ImDrawList::PathArcTo(struct ImVec2 const &,float,float,float,int)" (?PathArcTo@ImDrawList@@QEAAXAEBUImVec2@@mmmh@Z)
1>imguid.lib(imgui_widgets.cpp.obj) : error LNK2001: unresolved external symbol __imp_sinf
1>imguid.lib(imgui_widgets.cpp.obj) : error LNK2019: unresolved external symbol __imp_atof referenced in function "int __cdecl ImGui::RoundScalarWithFormatT(char const *,int,int)" (??$RoundScalarWithFormatT@H@ImGui@@YAHPEBDHH@Z)
1>imguid.lib(imgui_widgets.cpp.obj) : error LNK2019: unresolved external symbol __imp_atan2f referenced in function "bool __cdecl ImGui::ColorPicker4(char const *,float * const,int,float const *)" (?ColorPicker4@ImGui@@YA_NPEBDQEAMHPEBM@Z)
1>imguid.lib(imgui_widgets.cpp.obj) : error LNK2019: unresolved external symbol __imp_logf referenced in function "float __cdecl ImLog(float)" (?ImLog@@yamm@Z)
1>imguid.lib(imgui_widgets.cpp.obj) : error LNK2019: unresolved external symbol __imp_powf referenced in function "float __cdecl ImPow(float,float)" (?ImPow@@yammm@Z)
1>..\build\bin\Debug\windows\x86_64\test\test.exe : fatal error LNK1120: 15 unresolved externals
1>Done building project "test.vcxproj" -- FAILED.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========

I am using VS-C++20-64bits. Could you please help me?

MacQuant commented 1 year ago

I read online this might have to do with binding (Glad/Glfw) but not sure what exactly (might be un-related) here. I am doubting if even vcpkg supports Dear ImGui.

ocornut commented 1 year ago

It's a problem with Visual Studio standard libraries version mismatching, you seem to be linking with both MSVCRT and MSVCRTD. Not a problem specific to Dear ImGui, and probably equally unrelated to Glad or GLFW.