epezent / implot

Immediate Mode Plotting
MIT License
4.71k stars 521 forks source link

LNK2019: unresolved external symbol "void __cdecl ImPlot::PlotBarGroups<double [1]>(... #548

Open nluka opened 9 months ago

nluka commented 9 months ago

Hi,

Trying to integrate ImPlot into my existing ImGui application, but getting a linker error:

My compilation pipeline looks like:

compile_imgui_debug.bat

@call cl.exe ^
src/imgui/imgui.cpp ^
src/imgui/imgui_demo.cpp ^
src/imgui/imgui_draw.cpp ^
src/imgui/imgui_tables.cpp ^
src/imgui/imgui_widgets.cpp ^
src/imgui/imgui_impl_glfw.cpp ^
src/imgui/imgui_impl_opengl3.cpp ^
src/imgui/implot_items.cpp ^
src/imgui/implot.cpp ^
src/libs/stb_image.c ^
/nologo ^
/std:c++20 ^
/W4 ^
/WX ^
/nologo ^
/EHsc ^
/Fo:obj_debug\ ^
/c ^
/I"C:/code/glfw"

precompile_debug.bat

@call cl.exe ^
/c ^
/Ycstdafx.hpp ^
src/stdafx.cpp ^
/Yustdafx.hpp ^
/Fo:obj_debug\ ^
/Fe:bin\swan_debug.exe ^
/Fd:bin\vc140_debug.pdb ^
/I"C:/code/glfw" ^
/I"C:/code/boost_1_80_0" ^
/std:c++20 ^
/nologo ^
/W4 ^
/EHsc ^
/MP ^
/MT ^
/D_CRT_SECURE_NO_WARNINGS ^
/Zi ^
/link ^
/DEBUG:FULL ^
/NODEFAULTLIB:MSVCRTD ^
/NODEFAULTLIB:LIBCMT ^
/LIBPATH:"C:/code/glfw" ^
/LIBPATH:"C:/code/boost_1_80_0/stage/lib" ^
glfw3.lib ^
opengl32.lib ^
gdi32.lib ^
shell32.lib ^
kernel32.lib ^
msvcrt.lib ^
ole32.lib ^
shlwapi.lib ^
Pathcch.lib

compile_debug.bat

@call cl.exe ^
src/all_in_one.cpp ^
obj_debug/imgui_demo.obj ^
obj_debug/imgui_draw.obj ^
obj_debug/imgui_impl_glfw.obj ^
obj_debug/imgui_impl_opengl3.obj ^
obj_debug/imgui_tables.obj ^
obj_debug/imgui_widgets.obj ^
obj_debug/imgui.obj ^
obj_debug/implot.obj ^
obj_debug/implot_items.obj ^
obj_debug/stb_image.obj ^
obj_debug/stdafx.obj ^
/Fo:obj_debug\ ^
/Fe:bin\swan_debug.exe ^
/Fd:bin\vc140_debug.pdb ^
/Yustdafx.hpp ^
/I"C:/code/glfw" ^
/I"C:/code/boost_1_80_0" ^
/std:c++20 ^
/nologo ^
/W4 ^
/EHsc ^
/MP ^
/MT ^
/D_CRT_SECURE_NO_WARNINGS ^
/Zi ^
/link ^
/NATVIS:swan.natvis ^
/DEBUG:FULL ^
/NODEFAULTLIB:MSVCRTD ^
/NODEFAULTLIB:LIBCMT ^
/LIBPATH:"C:/code/glfw" ^
/LIBPATH:"C:/code/boost_1_80_0/stage/lib" ^
glfw3.lib ^
opengl32.lib ^
gdi32.lib ^
shell32.lib ^
kernel32.lib ^
msvcrt.lib ^
ole32.lib ^
shlwapi.lib ^
Pathcch.lib ^
Dbghelp.lib

When running compile_debug.bat, I get linker error:

===  .\compile_debug ===
all_in_one.cpp
all_in_one.obj : error LNK2019: unresolved external symbol "void __cdecl ImPlot::PlotBarGroups<double [1]>(char const * const * const,double const (*)[1],int,int,double,double,int)" (??$PlotBarGroups@$$BY00N@ImPlot@@YAXQEBQEBDPEAY00$$CBNHHNNH@Z) referenced in function "void __cdecl render_debug_info(struct explorer_window &,unsigned __int64)" (?render_debug_info@@YAXAEAUexplorer_window@@_K@Z)
bin\swan_debug.exe : fatal error LNK1120: 1 unresolved externals

I drew a diagram in an attempt to find the oversight, but I don't see it... image

I'm guessing the problem is somehow related to ImPlot::PlotBarGroups being a function template, but I am lost otherwise. I'm clearly unaware of some crucial concept about template compilation, hoping someone here can help...