【问题标题】:How to link to VTK library on Windows using g++如何使用 g++ 链接到 Windows 上的 VTK 库
【发布时间】:2023-03-09 07:40:02
【问题描述】:

我想通过命令行编译一个使用VTK库的简单程序:

g++ -IC:\VTK\Install\includes\vtk-5.10 SimpleTest.cpp -LC:\VTK\Install\lib
\vtk_5.10 -lvtkCommon -lvtkGraphics

SimpleTest.cpp

#include "vtkConeSource.h"

int main()
{
    vtkConeSource* cone = vtkConeSource::New();
    cone->SetHeight(5.0);   
    return 1;   
}

但我总是收到很多关于“未定义引用”的错误。例如:

C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x1c): 未定义对 `vtkInformationVector::GetInformationObject(int)' 的引用

C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x24): 未定义引用 `vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES()'

C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x36): 未定义引用`vtkInformation::Set(vtkInformationIntegerKey*, int)'

C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x85): 未定义引用`vtkPolyDataAlgorithm::PrintSelf(std:: ostream&, vtkIndent)'

C:\VTK\Install\lib\vtk_5.10/libvtkGraphics.a(vtkConeSource.cxx.obj):vtkConeSource.cxx:(.text+0x9f): 未定义对 `operator

还有更多...

我不知道我是否使用了错误的 g++ 语法,或者我的 VTK 库是否有问题。

我正在使用: VTK 5.10.1

minGW 4.7.2,32 位

VTK 是使用 MinGW 使用 CMake 2.8.11.2 从源代码编译的

更新: 我确实找到了关于这个的教程http://vtkblog.blogspot.com/2008/05/build-vtk-from-source-using-mingwmsys.html。但是我使用 minGW32-make 而不是安装 MSYS 并使用它的“make”。这可能是问题的一部分吗?

【问题讨论】:

  • 我建议您使用 CMake 为您的应用程序生成 makefile。 CMake 将为您处理库依赖项。

标签: vtk mingw32


【解决方案1】:

作为第一个测试,尝试明确包含 Install\lib\vtk_5.10 中包含的所有 vtk 库 - 以确保那些未定义的引用不是来自那些缺少的库。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    相关资源
    最近更新 更多