Static linking help needed when including the viz module (VTK)
Hey all!
I'm having an issue I've been fighting with all weekend. I'm trying to build a fairly simple example which uses the viz module in C++. I've built OpenCV 3.4 and OpenCV-contrib along with VTK 8.1.0 as static libs and all seems to be well there. But after adding all the libs and appropriate includes I get 19 build errors I can't seem to resolve and they all seem to be related to the opengl libraries within vtk.
opencv_viz340d.lib(opencv_viz_pch.obj) : error LNK2019: unresolved external symbol "void __cdecl vtkRenderingOpenGL2_AutoInit_Construct(void)" (?vtkRenderingOpenGL2_AutoInit_Construct@@YAXXZ) referenced in function "public: __thiscall vtkRenderingCore_AutoInit::vtkRenderingCore_AutoInit(void)" (??0vtkRenderingCore_AutoInit@@QAE@XZ)
opencv_viz340d.lib(opencv_viz_pch.obj) : error LNK2019: unresolved external symbol "void __cdecl vtkRenderingOpenGL2_AutoInit_Destruct(void)" (?vtkRenderingOpenGL2_AutoInit_Destruct@@YAXXZ) referenced in function "public: __thiscall vtkRenderingCore_AutoInit::~vtkRenderingCore_AutoInit(void)" (??1vtkRenderingCore_AutoInit@@QAE@XZ)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "public: virtual void __thiscall vtkOpenGLGL2PSHelper::PrintSelf(class std::basic_ostream<char,struct std::char_traits<char> > &,class vtkIndent)" (?PrintSelf@vtkOpenGLGL2PSHelper@@UAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@VvtkIndent@@@Z) referenced in function "public: virtual void __thiscall vtkOpenGLGL2PSHelperImpl::PrintSelf(class std::basic_ostream<char,struct std::char_traits<char> > &,class vtkIndent)" (?PrintSelf@vtkOpenGLGL2PSHelperImpl@@UAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@VvtkIndent@@@Z)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "protected: __thiscall vtkOpenGLGL2PSHelper::vtkOpenGLGL2PSHelper(void)" (??0vtkOpenGLGL2PSHelper@@IAE@XZ) referenced in function "protected: __thiscall vtkOpenGLGL2PSHelperImpl::vtkOpenGLGL2PSHelperImpl(void)" (??0vtkOpenGLGL2PSHelperImpl@@IAE@XZ)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "protected: virtual __thiscall vtkOpenGLGL2PSHelper::~vtkOpenGLGL2PSHelper(void)" (??vtkOpenGLGL2PSHelper@@MAE@XZ) referenced in function "protected: virtual __thiscall vtkOpenGLGL2PSHelperImpl::~vtkOpenGLGL2PSHelperImpl(void)" (??1vtkOpenGLGL2PSHelperImpl@@MAE@XZ)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "public: unsigned int __thiscall vtkTransformFeedback::GetBytesPerVertex(void)const " (?GetBytesPerVertex@vtkTransformFeedback@@QBEIXZ) referenced in function "public: virtual void __thiscall vtkOpenGLGL2PSHelperImpl::ProcessTransformFeedback(class vtkTransformFeedback *,class vtkRenderer *,float * const)" (?ProcessTransformFeedback@vtkOpenGLGL2PSHelperImpl@@UAEXPAVvtkTransformFeedback@@PAVvtkRenderer@@QAM@Z)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol "public: unsigned int __thiscall vtkTransformFeedback::GetBufferSize(void)const " (?GetBufferSize@vtkTransformFeedback@@QBEIXZ) referenced in function "public: virtual void __thiscall vtkOpenGLGL2PSHelperImpl::ProcessTransformFeedback(class vtkTransformFeedback *,class vtkRenderer *,float * const)" (?ProcessTransformFeedback@vtkOpenGLGL2PSHelperImpl@@UAEXPAVvtkTransformFeedback@@PAVvtkRenderer@@QAM@Z)
vtkRenderingGL2PSOpenGL2-8.1.lib(vtkOpenGLGL2PSHelperImpl.obj) : error LNK2019: unresolved external symbol __imp__glGetDoublev@8 referenced in function "protected: static void __cdecl vtkOpenGLGL2PSHelperImpl::GetTransformParameters(class vtkRenderer *,class vtkMatrix4x4 *,class vtkMatrix4x4 *,double * const,double * const,double * const)" (?GetTransformParameters@vtkOpenGLGL2PSHelperImpl@@KAXPAVvtkRenderer@@PAVvtkMatrix4x4@@1QAN22@Z)
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function _gl2psDrawImageMap
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function _gl2psDrawImageMap
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glFeedbackBuffer@12 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glGetBooleanv@8 referenced in function _gl2psDrawPixels
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glGetFloatv@8 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glGetIntegerv@8 referenced in function _gl2psBeginPage
vtkgl2ps-8.1.lib(gl2ps.obj) : error LNK2019: unresolved external symbol __imp__glIsEnabled@4 referenced in function ...
"unresolved external symbol" -> means you have included some Headers & corresponding linking is failing. Try to include opengl32.lib, glu32.lib in your project settings.
thanks that part I understood lol ;) Does glew need to be built along with VTK? I didn't see those lib files generated anywhere, I had thought VTK shipped with opengl libs built in.
These are OpenGL related libs that comes with your OS itself. You can find the path of those libs here