1、VTK在VS下的安装方法VS2010 安装配置VTKVTK5.10.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 FilesVTKVTKsourcecode, 将vtkdata-5.10.1.zip解压到D:Program FilesVTKVTKdata3. 解压 cmake
2、-2.8.2-win32-x86.zip,运行解压目录bincmake-gui.exe,设置sourse code目录为D:Program FilesVTK VTKsourcecode ,build目录为D:Program FilesVTKVTKbin按 configure 按钮,选Visual Studio 10编译器(这里即使是win7 64位的也建议不要选VS2010 W64,不然你就等着悲剧吧!0XC000007B这个牛逼的错误等着你!劳资装了4天都这样选的,MLGBD),然后cmake会描所需要的文件。选中 Advanced 再按 configure,可以看到一个vtk_use_gu
3、isupport,选择它,再按 configure, 选vtk_use_mfc,再configure,configure的次数是无所谓的。 vtk_data_root: 目的是告诉cmake,vtk 需要的数据都在哪里,我们的数据在c:/vtk/vtkdata/(2)cmake_install_prefix: 虽然网上说默认就好。但是我安装时出了问题。强烈建议该项的位置填VTK源程序和数据等文件的上一级文件的位置,即若vtk-5.10.1.zip 解压到D:Program FilesVTKVTKsourcecode,则此处填D:Program FilesVTK。build_examples:
4、就是询问是否编译 vtk 中的例子,你在看这个教程,说明肯定是初次用VTK,建议选上。build_shared_libs: 如果设置为off,就只会生成lib 文件,用于开发肯定是够了。如果设置为on,将会多生成 dll 文件,这些dll需要拷到windows/system目录下。如果用静态库编程,即off时,应用程序可以独立运行,尺寸也比较大,如果用动态库编程,即on时,应用程序必须找到动态库才能运行,但尺寸可以做得比较小。建议选On, 我试过选OFF,所谓的静态编译,但之后新建一个项目时,还是会出现找不到文件的问题。vtk_use_parallel: 对于想用vtk 做并行计算的朋友,要把
5、这个选上,对于只想学学vtk 的,保持默认 off 所有项目会变成灰色后后可以点击 Generate,完成时会提示 Generating done,此时关闭cmake。4. 用 vc+2010打开 D:Program FilesVTKVTKbinUtilitiesMaterialLibrary目录下的 MaterialLibrary.sln 文件,右键点击All_Build选择重新生成。5. 若 build_shared_libs 选择On,把D:Program FilesVTKVTKbinbinDebug里生成的vtksys.dll文件拷到windows/system目录下。或者打开VS20
6、10的属性管理器(视图-其他窗口-属性管理器),双击任意“Microsoft.Cpp.Win32.user”,弹出属性页,在里面VC+目录的 Library Directories 中将bin文件夹中的Debug包括进去(建议两种方法都用)。6. 打开D:Program FilesVTKVTKbin目录下的VTK.sln,右键点击All_Build选择重新生成。 若build_shared_libs选择On,中途涉及MFC的示例会出错,对应的解决办法为:错误Link错误:a.在Solution Explorer中分别找到vtkDLG、vtkMDI、vtkSDI、vtkMFC这四个项目,右键Pr
7、opertiesConfiguration PropertiesLinkerInput在Additional Dependencies中添加.binDebugvtkIO.lib b.再找到Win32SampleMFC这个项目,与以上类似地在Additional Dependencies中添加.binDebugvtkIO.lib这样,就为这些项目加入了vtkIO.lib库。上述方法可能失效,可采用下面的方法在vtkDLG、vtkMDI、vtkSDI、vtkMFC、Win32SampleMF项目的CMaklist.txt中修改。打开CMakelist.txt, 在TARGET_LINK_LIBRA
8、RIES中添入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、vtkMFCa.打开前四个
9、工程源文件中的stdAfx.h,在四个工程下的项中的.h文件中可以找到。另外可以打开D:Program FilesVTK,利用文件搜索功能搜寻,找到后用VS2010打开修改(本人用后者,感觉较快)。b.在vtkMFC工程下的中,找到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 correspondin
10、g values for different platforms.#ifndef WINVER / Allow use of features specific to Windows 95 and Windows NT 4 or later.#define WINVER0x0601/ 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
11、 4 or later.#define _WIN32_WINNT0x0601/ 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_WINDOWS0x0601/ Change this to the appropriate value to t
12、arget Windows Me or later.#endif#endif#ifndef _WIN32_IE / Allow use of features specific to IE 4.0 or later.#define _WIN32_IE0x0800/ 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
13、4 or later.#ifndef WINVER#define WINVER0x0601#endif/ Define _WIN32_WINNT and _WIN32_IE to avoid the following error with Visual/ Studio 2008 SP1:/ C:Program FilesMicrosoft SDKsWindowsv6.0Aincludesdkddkver.h(217) :/ fatal error C1189: #error : _WIN32_WINNT settings conflicts with _WIN32_IE/ setting#i
14、fndef _WIN32_WINNT#define _WIN32_WINNT0x0601/ =_WIN32_WINNT_NT4#endif#ifndef _WIN32_IE#define _WIN32_IE0x0800/=_WIN32_IE_IE60SP1#endif此时,应该没有问题了。若出现cannot find vtkMFC.lib则是由于cmake阶段未勾选vtk_use_mfc7.将D:Program FilesVTKVTKbinbin debug这个文件夹选择此中所有的DLL后缀的文件全部复制到c:windowssystem32(调试时推荐),或者拷贝到VC项目可执行文件所在位置(
15、安装到其他机器时拷贝)。8.用VS2010打开D:Program FilesVTKVTKbin ExamplesAllVTKExamples.sln,选择Cone项目,右键set as active project(VC不熟的人一定要记得这个!),然后选择调试-启动新实例,这时可以看到正确运行的程序了。9. 新建项目Test(控制台应用程序空项目),增加Test.cpp文件,用Cone6.cxx的文件内容覆盖Test.cpp的内容。#includevtkConeSource.h#includevtkPolyDataMapper.h#includevtkRenderWindow.h#includ
16、evtkCamera.h#includevtkActor.h#includevtkRenderer.h#includevtkProperty.hintmain()vtkConeSource*cone=vtkConeSource:New();cone-SetHeight(3.0);cone-SetRadius(1.0);cone-SetResolution(10);vtkPolyDataMapper*coneMapper=vtkPolyDataMapper:New();coneMapper-SetInputConnection(cone-GetOutputPort();vtkActor*cone
17、Actor=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);inti;for(i=0;iRender();ren1-GetActiveCamera()-Azimuth(i);cone
18、-Delete();coneMapper-Delete();coneActor-Delete();ren1-Delete();renWin-Delete();return0;.GeneratedFiles;.;$(QTDIR)include;.GeneratedFiles$(ConfigurationName);$(QTDIR)includeQtCore;$(QTDIR)includeQtGui;D:Program FilesPCL 1.6.03rdPartyVTKincludevtk-5.10;%(AdditionalIncludeDirectories)$(QTDIR)lib;D:Prog
19、ram FilesPCL 1.6.03rdPartyVTKlibvtk-5.10;%(AdditionalLibraryDirectories)qtmaind.lib;QtCored4.lib;QtGuid4.lib;opengl32.lib;pcl_kdtree_debug.lib;pcl_io_debug.lib;pcl_search_debug.lib;pcl_segmentation_debug.lib;pcl_apps_debug.lib;pcl_features_debug.lib;pcl_filters_debug.lib;pcl_visualization_debug.lib;
20、pcl_common_debug.lib;flann_cpp_s-gd.lib;libboost_system-vc100-mt-gd-1_47.lib;libboost_filesystem-vc100-mt-gd-1_47.lib;libboost_thread-vc100-mt-gd-1_47.lib;libboost_date_time-vc100-mt-gd-1_47.lib;libboost_iostreams-vc100-mt-gd-1_47.lib;Cosmo.lib;LSDyna.lib;MapReduceMPI.lib;mpistubs.lib;QVTK.lib;VPIC.
21、lib;vtkalglib.lib;vtkcharts.lib;vtkCommon.lib;vtkDICOMParser.lib;vtkexoIIc.lib;vtkexpat.lib;vtkFiltering.lib;vtkfreetype.lib;vtkftgl.lib;vtkGenericFiltering.lib;vtkGeovis.lib;vtkGraphics.lib;vtkhdf5.lib;vtkhdf5_hl.lib;vtkHybrid.lib;vtkImaging.lib;vtkInfovis.lib;vtkIO.lib;vtkjpeg.lib;vtklibxml2.lib;v
22、tkmetaio.lib;vtkMFC.lib;vtkNetCDF.lib;vtkNetCDF_cxx.lib;vtkParallel.lib;vtkpng.lib;vtkproj4.lib;vtkQtChart.lib;vtkRendering.lib;vtksqlite.lib;vtksys.lib;vtktiff.lib;vtkverdict.lib;vtkViews.lib;vtkVolumeRendering.lib;vtkWidgets.lib;vtkzlib.lib;D:Program FilesPCL 1.6.03rdPartyVTKVTKBINbinDebugQVTKWidg
23、etPlugin.lib;%(AdditionalDependencies)9.2项目属性-配置属性-VC+目录-包含目录,拷入入下述内容:D:Program FilesPCL 1.6.03rdPartyVTKVTKBIN;D:Program FilesPCL 1.6.03rdPartyVTKVTKBINbin;D:Program FilesPCL 1.6.03rdPartyVTKVTKGenericFiltering;D:Program FilesPCL 1.6.03rdPartyVTKVTKCommon;D:Program FilesPCL 1.6.03rdPartyVTKVTKIO;D:
24、Program FilesPCL 1.6.03rdPartyVTKVTKFiltering;D:Program FilesPCL 1.6.03rdPartyVTKVTKRendering;D:Program FilesPCL 1.6.03rdPartyVTKVTKGraphics;D:Program FilesPCL 1.6.03rdPartyVTKVTKVolumeRendering;D:Program FilesPCL 1.6.03rdPartyVTKVTKImaging;D:Program FilesPCL 1.6.03rdPartyVTKVTKHybrid;D:Program File
25、sPCL 1.6.03rdPartyVTKVTKGUISupport;D:Program FilesPCL 1.6.03rdPartyVTKVTK Utilities;D:Program FilesPCL 1.6.03rdPartyVTKVTKBIN Utilities;D:Program FilesPCL 1.6.03rdPartyVTKVTKParallel;D:Program FilesPCL 1.6.03rdPartyVTKVTKWidgets;D:Program FilesPCL 1.6.03rdPartyBoostinclude;D:Program FilesPCL 1.6.03r
26、dPartyEigeninclude;D:Program FilesPCL 1.6.03rdPartyFLANNinclude;D:Program FilesPCL 1.6.03rdPartyQhullinclude;D:Program FilesOpenNIInclude;D:Program FilesPCL 1.6.0includepcl-1.6;D:Qt4.8.0include;D:Program FilesPCL 1.6.03rdPartyVTKincludevtk-5.10;$(IncludePath)9.1项目属性-配置属性-VC+目录-库目录:D:Program FilesVTK
27、VTKbinbindebug若出现无法找到vtkRendering.dll等错误,则是由于该环境变量未配置正确D:Program FilesPCL 1.6.03rdPartyBoostlib;D:Program FilesPCL 1.6.03rdPartyEigenbin;D:Program FilesPCL 1.6.03rdPartyFLANNlib;D:Program FilesPCL 1.6.03rdPartyQhulllib;D:Program FilesPCL 1.6.0lib;D:Program FilesOpenNILib;D:Qt4.8.0lib;D:Program Files
28、PCL 1.6.03rdPartyVTKVTKBINbinRelease;$(LibraryPath)(注意:网上很多配置方法在Additionalincludedirectories(附加包含路径)没有添加D:Program FilesVTKVTKbin; D:Program FilesVTKVTKbinbin;结果出现错误提示:无法打开包括文件:“vtkConfigure.h”:Nosuchfileordirectory)9.3位于项目属性-链接器-输入-附加依赖项,拷入下述内容(下面有些lib文件已经被附加进去了,就不需要再添加进去):opengl32.lib kernel32.lib
29、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 v
30、tkjpeg.libvtkNetCDF.lib vtkpng.lib vtkRendering.lib vtksys.lib vtktiff.lib vtkVolumeRendering.lib vtkWidgets.lib vtkzlib.lib qtmaind.libQtCored4.libQtGuid4.libopengl32.libpcl_kdtree_debug.libpcl_io_debug.libpcl_search_debug.libpcl_segmentation_debug.libpcl_apps_debug.libpcl_features_debug.libpcl_filters_debug.libpcl
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1