我是 vtk 的新手,我想使用 vtkCharts 库。在 Linux 和 Windows 中,我编译了 vtk 并设法处理了大部分示例。
唯一麻烦的例子是那些包含图表库的例子,例如链接中的那个:
当我编译时,在 Visual Studio 中它给出了一些链接错误。下面是一段。我没有忘记包含 vtkCharts 库。
1>vtkCharts.lib(vtkContextView.obj) : error LNK2019: unresolved external symbol "protected: virtual __thiscall vtkRenderView::~vtkRenderView(void)" (??1vtkRenderView@@MAE@XZ) referenced in function "protected: virtual __thiscall vtkContextView::~vtkContextView(void)" (??1vtkContextView@@MAE@XZ) 1>vtkCharts.lib(vtkContextView.obj) : error LNK2019: unresolved external symbol "public: virtual void __thiscall vtkRenderView::SetDisplayHoverText(bool)" (?SetDisplayHoverText@vtkRenderView@@UAEX_N@Z) referenced in function "protected: __thiscall vtkContextView::vtkContextView(void)" (??0vtkContextView@@IAE@XZ) 1>vtkCharts.lib(vtkContextView.obj) : error LNK2019: unresolved external symbol "protected: __thiscall vtkRenderView::vtkRenderView(void)" (??0vtkRenderView@@IAE@XZ) referenced in function "protected: __thiscall vtkContextView::vtkContextView(void)" (??0vtkContextView@@IAE@XZ) 1>vtkCharts.lib(vtkContextView.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall vtkView::Update(void)" (?Update@vtkView@@UAEXXZ) 1>vtkCharts.lib(vtkContextView.obj) : error LNK2001: unresolved external symbol "public: virtual void __thiscall vtkRenderView::ApplyViewTheme(class vtkViewTheme *)" (?ApplyViewTheme@vtkRenderView@@UAEXPAVvtkViewTheme@@@Z) 1>vtkCharts.lib(vtkContextView.obj) : error LNK2001: unresolved external symbol "protected: virtual void __thiscall vtkRenderView::ProcessEvents(class vtkObject *,unsigned long,void *)" (?ProcessEvents@vtkRenderView@@MAEXPAVvtkObject@@KPAX@Z)
在 Code::Blocks 中,使用 GCC,它给出如下错误:
./VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|38|error: expected class-name before ‘{’ token| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|40|error: ‘vtkContextItem’ does not name a type| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|40|error: ‘vtkContextItem’ has not been declared| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|40|error: invalid static_cast from type ‘vtkObjectBase*’ to type ‘vtkChart*’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h||In member function ‘virtual vtkObjectBase* vtkChart::NewInstanceInternal() const’:| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|40|error: ‘New’ is not a member of ‘vtkChart’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h||In member function ‘virtual vtkAnnotationLink* vtkChart::GetAnnotationLink()’:| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|104|error: ‘class vtkChart’ has no member named ‘GetDebug’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|104|error: ‘class vtkChart’ has no member named ‘GetClassName’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|104|error: ‘class vtkChart’ has no member named ‘GetClassName’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h||In member function ‘virtual void vtkChart::SetGeometry(int, int)’:| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|108|error: ‘class vtkChart’ has no member named ‘GetDebug’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|108|error: ‘class vtkChart’ has no member named ‘GetClassName’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|108|error: ‘class vtkChart’ has no member named ‘GetClassName’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|108|error: ‘class vtkChart’ has no member named ‘Modified’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h||In member function ‘virtual int* vtkChart::GetGeometry()’:| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|109|error: ‘class vtkChart’ has no member named ‘GetDebug’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|109|error: ‘class vtkChart’ has no member named ‘GetClassName’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|109|error: ‘class vtkChart’ has no member named ‘GetClassName’| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h||In member function ‘virtual void vtkChart::GetGeometry(int&, int&)’:| ../VTK-build/VTK-5.6/VTK/Charts/vtkChart.h|109|error: ‘class vtkChart’ has no member named ‘GetDebug’|
我在两个平台上都使用 vtk 5-6。我想知道为什么会出现此错误。
谢谢。
最佳答案
I didn't forget to include the vtkCharts library.
那么您可能忘记包含 vtkHybrid 库。请注意 cmake 文件中的最后一行。
关于c++ - vtkCharts 库既不适用于 Visual Studio 也不适用于 GCC 编译器 - 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6401785/