Windows xp操作系统
vtk5.10.1(免费)
VS2010
CMake2.8(免费)
使用的环境、工具 我使用的是windows8.1操作系统,但是系统内装的工具、开发工具太多了,使用就用了虚拟机,在虚拟机中安装的是winXP SP3系统。安装VS2010、cmake2.8工具。其中安装VS2010、CMake过程略。
Windows下下载.zip扩展名文件,linux或者unix下载.tar.gz扩展名文件。Source为源代码文件,Data为数据文件,Documentation为文档文件,没有.zip文件,只能下载.tar.gz文件,使用解压工具解压,如果不用可以不下载。
准备文件夹 将下载的文件放到vtk5.10.1文件夹下,在此文件夹下分部建立bin、VTKData5.10.1、VTKSrc文件夹,分部存放CMake生成的项目文件及编译后的文件、VTK数据文件、VTK源代码。如下图
使用CMake工具生成项目文件 打开CMake程序,设置。Where is the source code为源码目录,设置为…/ vtk5.10.1/VTKSrc;Where to build the binaries为项目生成目录,这里设置为…/ vtk5.10.1/bin
设置完成后,点击“configure”按钮,第一次要求选择生成的vs项目版本,这里选择Visual Studio 10也就是vs2010,cmake自动扫描需要的文件和环境配置。完成后会有很多红色的列表,选择build_shared_libs(勾上)、build_examples(勾上),将编译共享库和vtk实例,如果不需要可以不勾选;vtk_data_root 数据文件夹…/…/ vtk5.10.1/ VTKData5.10.1;cmake_install_prefix,VS2010 install将include、bin、lib存放的路径,默认即可。 注意如果需要mfc的支持,需要勾选上Advanced,找到VTK_USE_GUISUPPORT进行勾选。由于出现的列表项太多,不好查找,可以通过search进行赛选。 之后再点击“configure”按钮,这时列表将出现VTK_USE_MFC,进行勾选,再次点击“configure”按钮,直到所有列表中红色全部消失为止。最h后点击“generate”将在bin文件夹下生成vs2010解决方案,包括100多个项目,根据cmake选项多少有关。
修改代码 在bin文件夹下打开解决方案,但是先别着急编译,需要修改几个文件StdAfx.h文件。修改如下// Modify the following defines if you have to target a platform prior to the ones specified below.// Refer to MSDN for the latest info on corresponding values for different platforms.#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.#define WINVER 0x //0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.#endif #ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.#define _WIN32_WINNT 0x //0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.#endif #if _MSC_VER >= 1300#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.#define _WIN32_WINDOWS 0x//0x0410 // Change this to the appropriate value to target Windows Me or later.#endif#endif #ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.#define _WIN32_IE 0x0800//0x0400 // Change this to the appropriate value to target IE 5.0 or later.#endif
编译源代码 使用Visual Studio 10进行打开,编译,因为打开的解决方案中项目源代码很多,所有需要很大的编译后的存储空间,大概需要1-2GB的硬盘存储空间;以及很长的编译时间,根据计算机的配置大概需要2-5个小时,请耐心等待。