VTK 7.1.0+window7_64位+QT5.5配置及第一个实例运行
来源:互联网 发布:衣服数据参考 编辑:程序博客网 时间:2024/06/01 10:10
踩坑已久,仅仅是配置就消耗大量的时间。今天终于成功运行第一个例子。感谢强大的网友。
其他配置版本多出现各种情况不明,难以寻找原因。最终确定该版本的配置参考VTK 7.1.0+Cmake3.7.1+VS2010+QT5.5(结合QT开发部分尚未测试,所用例程乃官网提供)
主要配置参考:
《VTK 7.0 & QT Creator 5.6 环境配置教程》https://wenku.baidu.com/view/ef13a7c94a7302768f9939ad.html (感谢)
配置环境:window 64 位。
前面步骤大致相同(QT部分由于版本问题,选择的是msvc2010-64bits)。
主要描述不同:
1.qt下载,并安装。QT5.5在设置时其他选项默认,最后选择MSVC2010 64bits,还有设置好环境变量
2.cmake下载并安装,建议与vtk同一个根目录下。
3.vtk下载,并安装(官网)
(cmake编译阶段,7.1.0版本跟7.0版本有锁不同,7.1.0版本多出许多MODULE选项,该部分默认即好)
BUILD-EXAMPLES --不选,需要例子直接后面到官网下载即可,节省编译时间
BUILD-TESTING --不选
BUILD-SHARED-LIBS--选(默认)
CMAKE-INSTALL-PREFIX-按照参考教程
VTK-RENDRING-BACKEND--作者建议改为OpenGL 由于第一次出错,后面又编译了一次改为OpenGL2,实际上编译的错误应该跟此处无关,建议按教程
其他同(注意用管理员身份运行后面的sln文件)
本文只是按照操作到了release版本编译并拷贝完,关于QT 控件拷贝部分由于教程多出一个F盘的目录,并没有继续操作。(后面QT部分问题不大)
至此基础配置完成。开始第一实例测试。
创建文件夹(不带中文),根目录下创建cmake.txt文件
//CMakeLists.txt
注意要区分大小写
cmake_minimum_required(VERSION 3.1) //(官网版本是2.8,编译会出错,这里根据cmake版本进行修改改为3.1.,可以参考水灵工作室出的《VTK图形开发进阶》,里面有关于cmake指令的描述)
PROJECT(CylinderRenderingProperties)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_executable(CylinderRenderingProperties MACOSX_BUNDLE CylinderRenderingProperties.cxx )
target_link_libraries(CylinderRenderingProperties ${VTK_LIBRARIES})
同一根目录下创建CXX文件(改为cpp文件时出错,该回来就好)
// 文件名对好CylinderRenderingProperties.cxx
#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
int main()
{
// This creates a polygonal cylinder model with eight circumferential facets.
//
vtkCylinderSource *cylinder = vtkCylinderSource::New();
cylinder->SetResolution(8);
// The mapper is responsible for pushing the geometry into the graphics
// library. It may also do color mapping, if scalars or other attributes
// are defined.
//
vtkPolyDataMapper *cylinderMapper = vtkPolyDataMapper::New();
cylinderMapper->SetInputConnection(cylinder->GetOutputPort());
// The actor is a grouping mechanism: besides the geometry (mapper), it
// also has a property, transformation matrix, and/or texture map.
// Here we set its color and rotate it -22.5 degrees.
vtkActor *cylinderActor = vtkActor::New();
cylinderActor->SetMapper(cylinderMapper);
cylinderActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
cylinderActor->RotateX(30.0);
cylinderActor->RotateY(-45.0);
// Create the graphics structure. The renderer renders into the
// render window. The render window interactor captures mouse events
// and will perform appropriate camera or actor manipulation
// depending on the nature of the events.
//
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
// Add the actors to the renderer, set the background and size
//
ren1->AddActor(cylinderActor);
ren1->SetBackground(0.1, 0.2, 0.4);
renWin->SetSize(200, 200);
// We'll zoom in a little by accessing the camera and invoking a "Zoom"
// method on it.
ren1->ResetCamera();
ren1->GetActiveCamera()->Zoom(1.5);
renWin->Render();
// This starts the event loop and as a side effect causes an initial render.
iren->Start();
// Exiting from here, we have to delete all the instances that
// have been created.
cylinder->Delete();
cylinderMapper->Delete();
cylinderActor->Delete();
ren1->Delete();
renWin->Delete();
iren->Delete();
return 0;
}
同一根目录下创建bin文件夹,存放例子的编译内容。
打开cmake,第一项选择cmake.txt所在目录,第二选bin.
成功后在bin 中找到sln文件,vs2010打开。F7生成——>control+F5运行,报错,找不到ALL_BUILD 文件,不怕,直接在--解决方案资源管理器中 把All_build 清除,以及最后一个大项zero_check清除.调了很久才解决,方法是,卸载所有无关工程,只保留一个你需要的工程,这时候ZERO_CHECK以及ALL_BUILD都没有必要存在了。(http://blog.csdn.net/jyl1999xxxx/article/details/50627600转自该网友的解决方案)
(只有该部分保存)
编译通过,生成成功,运行,出现第二个错误,vtkrenderingOpengl2.dll找不到,网上有的方案是初始化添加补充语句,结果不理想,最终其实是环境变量没有设置好。(http://blog.sina.com.cn/s/blog_5e3b04ee0102w296.html)参考该网友的配置,成功解决问题。
至此,程序愉快地跑起来。
- VTK 7.1.0+window7_64位+QT5.5配置及第一个实例运行
- ARToolkit在VS2010(Win7 64位)下的配置及第一个开发程序的编译与运行
- QT5.7.1+OpenCV3.0+win732位配置
- Android的环境配置及第一个Android程序的运行
- Android React Native环境配置以及第一个实例
- SeleniumWebdriver测试环境配置及第一个脚本实例_02
- ASP.NET Highcharts图表(1)-环境配置及第一个实例
- pcl1.8.0+QT5.7.0+vs2013 win7 x64环境配置以及第一个小程序实现
- Spring基础知识及第一个实例
- 【学习ARToolkit小记之初】 ARToolkit在VS2010(Win7 64位)下的配置及第一个开发程序的编译与运行
- 关于vs2015+qt5.x+vtk的配置
- 64位win7下,CodeBlock13.12配置GTK3.x环境以及第一个DEMO的执行
- solr5.5的搭建,以及第一个core的配置
- Android adt bundle 开发环境配置及第一个“Hello world”程序运行
- QT安装及第一个程序的运行
- 【React Native开发】React Native For Android环境配置以及第一个实例(1)
- 【React Native开发】React Native For Android环境配置以及第一个实例
- Android环境搭建以及第一个实例
- CentOS设置IP
- [译文]Android架构组件-App架构指南
- using语句下使用SqlDataReader异常:Invalid attempt to Read when reader is closed
- 内置锁(三)---- synchronized的几个要注意的对象监视器
- mysql常规命令
- VTK 7.1.0+window7_64位+QT5.5配置及第一个实例运行
- java开发遇到的简单问题
- 二叉树的顺序存储实现及遍历
- 【uva-124】Following Orders (拓扑排序)竟然自己写出了全排列的算法!
- 18届清华硕士收割18家互联网sp offer总结
- Python---思维导图
- Access denied for user 'root'@'localhost' (using password:YES)解决方法
- 《编程之美》介绍和pdf下载
- hdu1272小希的迷宫(并查集)