Reputation: 429
I installed VTK 7.1.1 as suggested here.
I'm working on a new project with the following code:
#include <iostream>
#include <vtk-7.1/vtkImageData.h>
#include <vtk-7.1/vtkMetaImageReader.h>
#include <vtk-7.1/vtkSmartPointer.h>
#include <vtk-7.1/vtkRenderer.h>
#include <vtk-7.1/vtkImageActor.h>
#include <vtk-7.1/vtkImageMapper3D.h>
#include <vtk-7.1/vtkRenderWindow.h>
#include <vtk-7.1/vtkRenderWindowInteractor.h>
int main()
{
vtkSmartPointer<vtkMetaImageReader> reader = vtkSmartPointer<vtkMetaImageReader>::New();
reader->SetFileName("Test.mhd");
reader->Update();
std::cout<<"Hello World";
return 0;
}
I am using the following to compile:
g++ -g -Wall -I /usr/local/include -L /usr/local/lib -o main main.cpp
However, I keep getting errors such as the following:
/usr/local/include/vtk-7.1/vtkSmartPointer.h:29: error: undefined reference to `vtkSmartPointerBase::~vtkSmartPointerBase()'
Any idea as to why? I think it might be the linking maybe?
Upvotes: 1
Views: 3210
Reputation: 74
Your assumption is correct the linker command is missing the required VTK libraries. Look in the following link for more details VTK in Makefiles.
For instance
g++ -g -Wall -I /usr/local/include -L/usr/local/lib -lvtkCommon
-lvtkFiltering -lvtkImaging -lvtkGraphics -lvtkGenericFiltering -lvtkIO
-lvtkRendering -lvtkVolumeRendering
To ease building your VTK applications you could use CMake
Upvotes: 1