打开cmake,将where is the source code的路径设置为原始资源的路径,我的是E:\VTK\VTK6.0.0;将where tobuild the binaries的路径设置为目标存放路径,我的是:E:\VTK\VTK_bin。
再按一次configure,直至都变成灰色,表示配置成功, 点击 Generate确认。
编译完成
选择二:低版本(VTK5.10.1)
找到vtkMFCwindow.cpp,将前面的宏定义修改为:
#ifndef WINVER
#define WINVER0x0501//你可改为更高版本
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501 // 这是我改的
#endif
编译完成
步骤三:修改环境变量,修改编译器链接
环境变量设置:我的电脑->属性->高级->环境变量->添加:E:\VTK\VTK_bin
将E:\VTK\bin中的.dll文件拷贝到C:\WINDOWS\system32中(注意:64位系统的为了保险起见,可能还需同时拷贝到C:\WINDOWS\sysWOW64中)。
找一个测试用例,新建一个cpp源代码文件,将以下代码拷入:
#include "stdafx.h"
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkProperty.h"
#include "windows.h"
int _tmain(int argc, _TCHAR* argv[])
{
vtkConeSource *cone = vtkConeSource::New();
cone->SetHeight( 3.0 );
cone->SetRadius( 1.0 );
cone->SetResolution( 10 );
vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
coneMapper->SetInputConnection( cone->GetOutputPort() );
vtkActor *coneActor = vtkActor::New();
coneActor->SetMapper( coneMapper );
vtkRenderer *ren1= vtkRenderer::New();
ren1->AddActor( coneActor );
ren1->SetBackground( 0.1, 0.2, 0.4 );
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer( ren1 );
renWin->SetSize( 300, 300 );
for (int i = 0; i < 360; ++i)
{
renWin->Render();
ren1->GetActiveCamera()->Azimuth( i );
Sleep(200);
}
cone->Delete();
coneMapper->Delete();
coneActor->Delete();
ren1->Delete();
renWin->Delete();
return 0;
}
#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkProperty.h"
#include "windows.h"
int _tmain(int argc, _TCHAR* argv[])
{
vtkConeSource *cone = vtkConeSource::New();
cone->SetHeight( 3.0 );
cone->SetRadius( 1.0 );
cone->SetResolution( 10 );
vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
coneMapper->SetInputConnection( cone->GetOutputPort() );
vtkActor *coneActor = vtkActor::New();
coneActor->SetMapper( coneMapper );
vtkRenderer *ren1= vtkRenderer::New();
ren1->AddActor( coneActor );
ren1->SetBackground( 0.1, 0.2, 0.4 );
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer( ren1 );
renWin->SetSize( 300, 300 );
for (int i = 0; i < 360; ++i)
{
renWin->Render();
ren1->GetActiveCamera()->Azimuth( i );
Sleep(200);
}
cone->Delete();
coneMapper->Delete();
coneActor->Delete();
ren1->Delete();
renWin->Delete();
return 0;
}
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
E:\VTKITK\VTK\lib\vtkalglib-6.0.lib
ws2_32.lib
E:\VTKITK\VTK\lib\vtkChartsCore-6.0.lib
E:\VTKITK\VTK\lib\vtkCommonColor-6.0.lib
E:\VTKITK\VTK\lib\vtkCommonComputationalGeometry-6.0.lib
E:\VTKITK\VTK\lib\vtkCommonCore-6.0.lib
E:\VTKITK\VTK\lib\vtkCommonDataModel-6.0.lib
E:\VTKITK\VTK\lib\vtkCommonExecutionModel-6.0.lib
E:\VTKITK\VTK\lib\vtkCommonMath-6.0.lib
E:\VTKITK\VTK\lib\vtkCommonMisc-6.0.lib
E:\VTKITK\VTK\lib\vtkCommonSystem-6.0.lib
E:\VTKITK\VTK\lib\vtkCommonTransforms-6.0.lib
E:\VTKITK\VTK\lib\vtkDICOMParser-6.0.lib
E:\VTKITK\VTK\lib\vtkDomainsChemistry-6.0.lib
E:\VTKITK\VTK\lib\vtkexpat-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersAMR-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersCore-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersExtraction-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersFlowPaths-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersGeneral-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersGeneric-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersGeometry-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersHybrid-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersHyperTree-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersImaging-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersModeling-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersParallel-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersParallelImaging-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersProgrammable-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersSelection-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersSources-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersStatistics-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersTexture-6.0.lib
E:\VTKITK\VTK\lib\vtkFiltersVerdict-6.0.lib
E:\VTKITK\VTK\lib\vtkfreetype-6.0.lib
E:\VTKITK\VTK\lib\vtkftgl-6.0.lib
E:\VTKITK\VTK\lib\vtkGeovisCore-6.0.lib
E:\VTKITK\VTK\lib\vtkgl2ps-6.0.lib
E:\VTKITK\VTK\lib\vtkhdf5_hl-6.0.lib
E:\VTKITK\VTK\lib\vtkGUISupportMFC-6.0.lib
E:\VTKITK\VTK\lib\vtkhdf5-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingColor-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingCore-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingFourier-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingGeneral-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingHybrid-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingMath-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingMorphological-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingSources-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingStatistics-6.0.lib
E:\VTKITK\VTK\lib\vtkImagingStencil-6.0.lib
E:\VTKITK\VTK\lib\vtkInfovisCore-6.0.lib
E:\VTKITK\VTK\lib\vtkInfovisLayout-6.0.lib
E:\VTKITK\VTK\lib\vtkInteractionImage-6.0.lib
E:\VTKITK\VTK\lib\vtkInteractionStyle-6.0.lib
E:\VTKITK\VTK\lib\vtkInteractionWidgets-6.0.lib
E:\VTKITK\VTK\lib\vtkIOAMR-6.0.lib
E:\VTKITK\VTK\lib\vtkIOCore-6.0.lib
E:\VTKITK\VTK\lib\vtkIOEnSight-6.0.lib
E:\VTKITK\VTK\lib\vtkIOExodus-6.0.lib
E:\VTKITK\VTK\lib\vtkIOExport-6.0.lib
E:\VTKITK\VTK\lib\vtkIOGeometry-6.0.lib
E:\VTKITK\VTK\lib\vtkIOImage-6.0.lib
E:\VTKITK\VTK\lib\vtkIOImport-6.0.lib
E:\VTKITK\VTK\lib\vtkIOInfovis-6.0.lib
E:\VTKITK\VTK\lib\vtkIOLegacy-6.0.lib
E:\VTKITK\VTK\lib\vtkIOLSDyna-6.0.lib
E:\VTKITK\VTK\lib\vtkIOMovie-6.0.lib
E:\VTKITK\VTK\lib\vtkIONetCDF-6.0.lib
E:\VTKITK\VTK\lib\vtkIOParallel-6.0.lib
E:\VTKITK\VTK\lib\vtkIOPLY-6.0.lib
E:\VTKITK\VTK\lib\vtkIOSQL-6.0.lib
E:\VTKITK\VTK\lib\vtkIOXML-6.0.lib
E:\VTKITK\VTK\lib\vtkIOXMLParser-6.0.lib
E:\VTKITK\VTK\lib\vtkjpeg-6.0.lib
E:\VTKITK\VTK\lib\vtkjsoncpp-6.0.lib
E:\VTKITK\VTK\lib\vtklibxml2-6.0.lib
E:\VTKITK\VTK\lib\vtkLocalExample-6.0.lib
E:\VTKITK\VTK\lib\vtkmetaio-6.0.lib
E:\VTKITK\VTK\lib\vtkNetCDF_cxx-6.0.lib
E:\VTKITK\VTK\lib\vtkNetCDF-6.0.lib
E:\VTKITK\VTK\lib\vtkoggtheora-6.0.lib
E:\VTKITK\VTK\lib\vtkParallelCore-6.0.lib
E:\VTKITK\VTK\lib\vtkpng-6.0.lib
E:\VTKITK\VTK\lib\vtkproj4-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingAnnotation-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingContext2D-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingCore-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingFreeType-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingFreeTypeOpenGL-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingGL2PS-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingHybridOpenGL-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingImage-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingLabel-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingLOD-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingOpenGL-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingVolume-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingVolumeAMR-6.0.lib
E:\VTKITK\VTK\lib\vtkRenderingVolumeOpenGL-6.0.lib
E:\VTKITK\VTK\lib\vtksqlite-6.0.lib
E:\VTKITK\VTK\lib\vtksys-6.0.lib
E:\VTKITK\VTK\lib\vtkTestingGenericBridge-6.0.lib
E:\VTKITK\VTK\lib\vtkTestingIOSQL-6.0.lib
E:\VTKITK\VTK\lib\vtkTestingRendering-6.0.lib
E:\VTKITK\VTK\lib\vtktiff-6.0.lib
E:\VTKITK\VTK\lib\vtkverdict-6.0.lib
E:\VTKITK\VTK\lib\vtkViewsContext2D-6.0.lib
E:\VTKITK\VTK\lib\vtkViewsCore-6.0.lib
E:\VTKITK\VTK\lib\vtkViewsGeovis-6.0.lib
E:\VTKITK\VTK\lib\vtkViewsInfovis-6.0.lib
E:\VTKITK\VTK\lib\vtkzlib-6.0.lib
结束啦!祝你成功