trlsmax / imgui-vtk

test on how to integrate vtk into glfw + imgui project
MIT License
107 stars 26 forks source link

Compilation error with VTK 9.0: undefined reference of the symbol '_ZN14vtkNamedColors3NewEv' #5

Closed renexdev closed 1 year ago

renexdev commented 3 years ago

Hi @trlsmax , I'm trying to test this very interesting project but unfortunately I'm getting an undefined reference of the symbol '_ZN14vtkNamedColors3NewEv' at compilation time. I copy the output

/usr/bin/c++     CMakeFiles/imgui_vtk.dir/main.cpp.o CMakeFiles/imgui_vtk.dir/glad/glad.c.o CMakeFiles/imgui_vtk.dir/imgui_impl_vtk.cpp.o CMakeFiles/imgui_vtk.dir/imgui/imgui.cpp.o CMakeFiles/imgui_vtk.dir/imgui/imgui_demo.cpp.o CMakeFiles/imgui_vtk.dir/imgui/imgui_draw.cpp.o CMakeFiles/imgui_vtk.dir/imgui/imgui_widgets.cpp.o CMakeFiles/imgui_vtk.dir/imgui/imgui_impl_glfw.cpp.o CMakeFiles/imgui_vtk.dir/imgui/imgui_impl_opengl3.cpp.o  -o imgui_vtk -Wl,-rpath,$VTK_INSTALL/lib -lpthread /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so -ldl $VTK_INSTALL/lib/libvtkInteractionStyle-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkRenderingFreeType-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkRenderingGL2PSOpenGL2-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkRenderingOpenGL2-9.0.so.9.0.1 $GLFW_INSTALL/lib/libglfw3.a $VTK_INSTALL/lib/libvtkfreetype-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkzlib-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkRenderingUI-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkRenderingCore-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkFiltersCore-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkCommonExecutionModel-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkCommonDataModel-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkCommonTransforms-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkCommonMisc-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkglew-9.0.so.9.0.1 /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /usr/lib/x86_64-linux-gnu/libX11.so $VTK_INSTALL/lib/libvtkCommonMath-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtkCommonCore-9.0.so.9.0.1 $VTK_INSTALL/lib/libvtksys-9.0.so.9.0.1 -ldl -lpthread -Wl,-rpath-link,$VTK_INSTALL/lib 
/usr/bin/ld: CMakeFiles/imgui_vtk.dir/main.cpp.o: referencia sin definir al símbolo '_ZN14vtkNamedColors3NewEv'
$VTK_INSTALL/lib/libvtkCommonColor-9.0.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Seems that this is a linking problem with the new vtk. Do you have and clue of what could be causing the error? I'm using Debian 9, vtk 9.0 and glfw 3.4.0. My vtk compilation options include:

RenderingGL2PSOpenGL2=YES
-DVTK_GROUP_ENABLE_Rendering=YES
-DVTK_GROUP_ENABLE_Imaging=YES
-DVTK_GROUP_ENABLE_Views=YES
-DVTK_MODULE_ENABLE_VTK_RenderingContextOpenGL2=YES
-DVTK_MODULE_ENABLE_VTK_RenderingFreeTypeFontConfig=YES

I lastly tried to add were two more vtk modules following the "color" reference name given in the output error, but nothing changes:

-DVTK_MODULE_ENABLE_VTK_CommonColor=YES                                  
-DVTK_MODULE_ENABLE_VTK_ImagingColor=YES

Thanks in advance for any help.

trlsmax commented 3 years ago

Did you checked if the file is missing or somewhere else ?

renexdev commented 3 years ago

I couldn't find _ZN14vtkNamedColors3NewEv neither in vtk directory nor in imgui-vtk (source or build)... any suggestion where to look at? Thanks,

renexdev commented 3 years ago

Maybe the problem arises with vtk 9.x, seems that the project works fine for the version you mention, that'svtk 8.2...

PetiteViking commented 3 years ago

I am pretty sure this got fixed by linking to vtkCommonColor. Try with lastest master.