Error with vtkRenderer

泪湿孤枕 提交于 2019-12-11 00:58:28

问题


I'm new to vtk, so I started by building vtk 8.1.1 with CMake and Visual Studio 2017, with the default options and the examples.

Many of the examples runs fine, but some of them gives an error:

This one is the CreateTree example, but the HelloWorld gives the same error.

I don't know if it has something to do with this issue.

I've also tried the solution from this question and this one. But when I add

#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);

right after all the includes, Visual Studio gives me this error:

1>CreateTree.obj : error LNK2019: unresolved external symbol "void __cdecl vtkRenderingOpenGL2_AutoInit_Construct(void)" (?vtkRenderingOpenGL2_AutoInit_Construct@@YAXXZ) referenced in function "public: __thiscall vtkRenderingOpenGL2_ModuleInit::vtkRenderingOpenGL2_ModuleInit(void)" (??0vtkRenderingOpenGL2_ModuleInit@@QAE@XZ)

1>CreateTree.obj : error LNK2019: unresolved external symbol "void __cdecl vtkRenderingOpenGL2_AutoInit_Destruct(void)" (?vtkRenderingOpenGL2_AutoInit_Destruct@@YAXXZ) referenced in function "public: __thiscall vtkRenderingOpenGL2_ModuleInit::~vtkRenderingOpenGL2_ModuleInit(void)" (??1vtkRenderingOpenGL2_ModuleInit@@QAE@XZ)

1>C:\vtkSource\bin\bin\Debug\CreateTree.exe : fatal error LNK1120: 2 unresolved externals

if I try VTK_MODULE_INIT(vtkRenderingWindow) or VTK_MODULE_INIT(vtkRenderingOpenGL) I get the same errors.

Also, examples like Delaunay3D only open a window that closes so fast I can't even see what it does have.


回答1:


Did you try adding the following line

vtkRendering${VTK_RENDERING_BACKEND}

to the set(VTK_Modules ...) command in the CMakeLists.txt for the HelloWorld or CreateTree projects just like it is suggested in the link you posted.

EDIT

Just to expand the explanation for beginners, the CMakeLists.txt is the path VTK-8.1.1\Examples\Infovis\Cxx. And the file should look like this:



来源:https://stackoverflow.com/questions/51796656/error-with-vtkrenderer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!