VTK在VS2010下的安装方法(已在好几台电脑上成功安装)

--------------------------可以编辑的精品文档,你值得拥有,下载后想怎么改就怎么改---------------------------

==========================================================

VS2010 安装配置VTK

VTK5.10.1 安装配置教程 1. 必须下载:

vtk-5.10.1.zip 源程序 vtkdata-5.10.1.zip 数据

(vtk相关安装程序下载:http://vtk.org) cmake-2.8.2-win32-x86.zip

(cmake程序下载:http://www.cmake.org/HTML/Index.html)

2. 将 vtk-5.10.1.zip 解压到D:\\Program Files\\VTK\\VTKsourcecode, 将vtkdata-5.10.1.zip解压到D:\\Program Files\\VTK\\VTKdata

3. 解压 cmake-2.8.2-win32-x86.zip,运行{解压目录}\\bin\\cmake-gui.exe,设置sourse code目录为D:\\Program Files\\VTK\\ VTKsourcecode \\,build目录为D:\\Program Files\\VTK\\VTKbin\\

按 configure 按钮,选Visual Studio 10编译器(这里即使是win7 64位的也建议不要选VS2010 W64,不然你就等着悲剧吧!!0XC000007B这个牛逼的错误等着你!!劳资装了4天都这样选的,MLGBD),然后cmake会描所需要的文件。

选中 Advanced 再按 configure,可以看到一个vtk_use_guisupport,选择它,再按 configure, 选vtk_use_mfc,再configure,configure的次数是无所谓的。 (1) vtk_data_root: 目的是告诉cmake,vtk 需要的数据都在哪里,我们的数据在 c:/vtk/vtkdata/

(2)cmake_install_prefix: 虽然网上说默认就好。但是我安装时出了问题。强烈建议该项的位置填VTK源程序和数据等文件的上一级文件的位置,即若vtk-5.10.1.zip 解压到D:\\Program Files\\VTK\\VTKsourcecode,则此处填D:\\Program Files\\VTK。

build_examples: 就是询问是否编译 vtk 中的例子,你在看这个教程,说明肯定是初次用VTK,建议选上。

build_shared_libs: 如果设置为off,就只会生成lib 文件,用于开发肯定是够了。如果设置为on,将会多生成 dll 文件,这些dll需要拷到windows/system目录下。如果用静态库编程,即off时,应用程序可以独立运行,尺寸也比较大,如果用动态库编程,即on时,应用程序必须找到动态库才能运行,但尺寸可以做得比较小。建议选On, 我试过选OFF,所谓的静态编译,但之后新建一个项目时,还是会出现找不到文件的问题。

vtk_use_parallel: 对于想用vtk 做并行计算的朋友,要把这个选上,对于只想学学vtk 的,保持默认 off

所有项目会变成灰色后后可以点击 Generate,完成时会提示 Generating done,此时关闭cmake。

--------------------------可以编辑的精品文档,你值得拥有,下载后想怎么改就怎么改---------------------------

==========================================================================

--------------------------可以编辑的精品文档,你值得拥有,下载后想怎么改就怎么改---------------------------

==========================================================

4. 用 vc++2010打开 D:\\Program Files\\VTK\\VTKbin\\Utilities\\MaterialLibrary目录下的 MaterialLibrary.sln 文件,右键点击All_Build选择重新生成。

5. 若 build_shared_libs 选择On,把D:\\Program Files\\VTK\\VTKbin\\bin\\Debug里生成的vtksys.dll文件拷到windows/system目录下。或者打开VS2010的属性管理器(视图->其他窗口->属性管理器),双击任意“Microsoft.Cpp.Win32.user”,弹出属性页,在里面VC++目录的 Library Directories 中将bin文件夹中的Debug包括进去(建议两种方法都用)。

6. 打开D:\\Program Files\\VTK\\VTKbin目录下的VTK.sln,右键点击All_Build选择重新生成。 若build_shared_libs选择On,中途涉及MFC的示例会出错, 对应的解决办法为: 错误① Link错误:

a.在Solution Explorer中分别找到vtkDLG、vtkMDI、vtkSDI、vtkMFC这四个项目,右键—>Properties—>Configuration Properties—>Linker—>Input—>在Additional Dependencies中添加..\\..\\..\\..\\..\\bin\\Debug\\vtkIO.lib

b.再找到Win32SampleMFC这个项目,与以上类似地在Additional Dependencies中添加..\\..\\..\\..\\bin\\Debug\\vtkIO.lib

这样,就为这些项目加入了vtkIO.lib库。

上述方法可能失效,可采用下面的方法在vtkDLG、vtkMDI、vtkSDI、vtkMFC、Win32SampleMF项目的CMaklist.txt中修改。打开CMakelist.txt, 在TARGET_LINK_LIBRARIES中添入vtkIO。

例如vtkSDI的CMakelist.txt中,TARGET_LINK_LIBRARIES (vtkSDI vtkMFC)应改为TARGET_LINK_LIBRARIES (vtkSDI vtkMFC vtkIO)。其他的项目修改类似。

错误②

This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended. 解决办法为:

找到五个工程:vtkDLG、vtkMDI、vtkSDI、Win32SampleMFC、vtkMFC a.打开前四个工程源文件中的stdAfx.h,

在四个工程下的项中的.h文件中可以找到。另外可以打开

D:\\Program Files\\VTK\\,利用文件搜索功能搜寻,找到后用VS2010打开修改(本人用后者,感觉较快)。

b.在vtkMFC工程下的< Resource Files>中,找到vtkMFCWindow.cpp打开修改

--------------------------可以编辑的精品文档,你值得拥有,下载后想怎么改就怎么改---------------------------

==========================================================================

--------------------------可以编辑的精品文档,你值得拥有,下载后想怎么改就怎么改---------------------------

==========================================================

4个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 0x0601 // 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 0x0601 // 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 0x0601 // 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 // Change this to the appropriate value to target IE 5.0 or later. #endif

红字对应的是win7版本。

vtkMFCWindow.cpp中的部分代码:

// Allow use of features specific to Windows 95 and Windows NT 4 or later. #ifndef WINVER #define WINVER 0x0601 #endif

// Define _WIN32_WINNT and _WIN32_IE to avoid the following error with Visual // Studio 2008 SP1:

// \// fatal error C1189: #error : _WIN32_WINNT settings conflicts with _WIN32_IE

--------------------------可以编辑的精品文档,你值得拥有,下载后想怎么改就怎么改---------------------------

==========================================================================

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4