Download VTK 5.10.1

Download VS2010

Download CMake 3.2.0

 

I assume you've already installed VS2010 and CMake 3.2.0 correctly.

 

Compile the VTK:

Start CMake 3.2.0, fill the source and destination:

source: C:/VTK5.10.1/VTK5.10.1

destination: C:/VTK5.10.1/VS2010

Click Configure and use Visual Studio 10 2010 to complie.

 

When first configure is done, select Grouped and Advanced.

BUILD_EXAMPLES [ON]

BUILD_TEST [ON]

CMAKE_INSTALL_PREFIX [C:/VTK5.10.1/VS2010_install]

CMAKE_USE_PTHREADS [OFF]

CMAKE_USE_WIN32_THREADS [ON]

 

click Configure again.

After configure is done (No errors show), click Generate.

 

Go back to your build folder, open VTK.sln, right click ALL_BUILD, choose Rebuild.

Wait a long time for make process, have a cup of coffee :)

After rebuild is done, right click INSTALL, choose Build.

 

Now, the configuration is done, enjoy it :)

 

Create a new empty project,

 

Project->Project Property->Configuration Properties->VC++Directories ->Include Directories:

C:\VTK5.10.1\VS2010C:\VTK5.10.1\VS2010\binC:\VTK5.10.1\VTK5.10.1\GenericFilteringC:\VTK5.10.1\VTK5.10.1\CommonC:\VTK5.10.1\VTK5.10.1\IOC:\VTK5.10.1\VTK5.10.1\FilteringC:\VTK5.10.1\VTK5.10.1\RenderingC:\VTK5.10.1\VTK5.10.1\GraphicsC:\VTK5.10.1\VTK5.10.1\olumeRenderingC:\VTK5.10.1\VTK5.10.1\ImagingC:\VTK5.10.1\VTK5.10.1\HybridC:\VTK5.10.1\VTK5.10.1\GUISupportC:\VTK5.10.1\VTK5.10.1\UtilitiesC:\VTK5.10.1\VS2010\UtilitiesC:\VTK5.10.1\VTK5.10.1\ParallelC:\VTK5.10.1\VTK5.10.1\WidgetsC:\VTK5.10.1\VS2010_install\include\vtk-5.10

 

Project->Project Property->Configuration Properties->VC++Directories ->Library Directories:

C:\VTK5.10.1\VS2010\bin\Release

 

Project->Project Property->Configuration Properties->Linker->Input:

opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib vtkCommon.lib vtkDICOMParser.lib vtkexoIIc.lib vtkexpat.lib vtkFiltering.lib vtkfreetype.lib vtkftgl.lib vtkGenericFiltering.lib vtkGraphics.lib vtkHybrid.lib vtkImaging.lib vtkIO.lib vtkjpeg.lib vtkNetCDF.lib vtkpng.lib vtkRendering.lib vtksys.lib vtktiff.lib vtkVolumeRendering.lib vtkWidgets.lib vtkzlib.lib 

 

Create a test.cpp file as below:

#include

#include

#include

#include

#include

#include

#include

#include

int main(int, char *[])

{

//Create a cone

vtkSmartPointer coneSource =

vtkSmartPointer::New();

coneSource->Update();

//Create a mapper and actor

vtkSmartPointer mapper =

vtkSmartPointer::New();

mapper->SetInputConnection(coneSource->GetOutputPort());

vtkSmartPointer actor =

vtkSmartPointer::New();

actor->SetMapper(mapper);

//Create a renderer, render window, and interactor

vtkSmartPointer renderer =

vtkSmartPointer::New();

vtkSmartPointer renderWindow =

vtkSmartPointer::New();

renderWindow->AddRenderer(renderer);

vtkSmartPointer renderWindowInteractor =

vtkSmartPointer::New();

renderWindowInteractor->SetRenderWindow(renderWindow);

//Add the actors to the scene

renderer->AddActor(actor);

renderer->SetBackground(.3, .2, .1); // Background color dark red

//Render and interact

renderWindow->Render();

renderWindowInteractor->Start();

return EXIT_SUCCESS;

}

 

If error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' occurs, please see solution here.

 

查看原文