1. 从vtk官网中下载VTK5.10.1及VTKData5.10.1。
http://www.vtk.org/VTK/resources/software.html
2.解压缩到目录,并创建一个fold存放cmake生成出来的projects文件。fold的目录层次如下:
3. 安装Python的头文件和静态库包: sudo apt-get install python-dev
ubuntu12.0系统自带了python2.7的版本,不过缺少一个文件patchlevel.h。需要从copy一份并放 在/usr/lib/python2.7下面。
4.cmake及cmake-gui的安装
sudo apt-get install cmake
sudo apt-get install cmake-qt-gui
5.安装Code::Blocks IDE c++编译工具并安装。
http://www.codeblocks.org/downloads/binaries
6. 打开Cmake-gui,配置cmake选项由于当前是为python编译的版本,具体配置如下:
步骤1:设置源码目录及生成的projects目录
步骤2:单击Configure ,并在弹出的对话框中选择CodeBlocks-Unix Makefiles and 其它的默认选项。
步骤3:单击finish就会执行Configure动作,等待完成。如果有错误需要解决,直到Configure Ok.一般需要做一下选择:
也有可能python_include_dir 需要手动制定系统python2.7 的 路径 /usr/include/python2.7.
如果遇到下面错误,需要copy patchlevel.h(copy python 2.7 下面copy)文件放到python include路径下面。
CMake Error at CMake/FindPythonLibs.cmake:112 (FILE):
file STRINGS file "/usr/include/python2.7/patchlevel.h" cannot be read.
如遇到如下错误,缺少必须的OpenGL库:
CMake Error at CMake/vtkTestGLX.cmake:212 (file):
file STRINGS file
"/root/project/VTK5.10.1/Rendering/OPENGL_INCLUDE_DIR-NOTFOUND/GL/glx.h"
cannot be read.
Call Stack (most recent call first):
Rendering/CMakeLists.txt:508 (INCLUDE)
Mesa,这是当前Linux平台上OpenGL的一个最好实现ftp://ftp.freedesktop.org/pub/mesa/9.0.1/
1> ./configure, error:makedepend is required to build Mesa
sudo apt-get install xutils-dev
2> ./configure, error: flex is needed to build Mesa
sudo apt-get install flex
3> ./configure, error: bison is needed to build Mesa
sudo apt-get install bison
4> ./configure, error: X11 development libraries needed for GLX
sudo apt-get install xorg-dev
5> ./configure,
error: Direct rendering requries libdrm>= 2.4.24
下载libdrm-2.4.33.tar.bz2,解压,安装
6> ./configure,
configure: error: Package requirements (x11 xext xdamage xfixes x11-xcb xcb-glx xxf86vm) were not met:
No package ""x11-xcb"" found
No package ""xcb-glx"" found
sudo apt-get install libx11-xcb-dev libxcb-glx0 libxcb-glx0-dev
7> ./configure,
No package ""libdrm_nouveau"" found
这个题目斗劲愁闷,在32位的ubuntu应当是经由过程vmware tools可以安装驱动Gallium 0.4 on llvmpipe(LLVM 0 x300),不知为何64位不可(不是很断定?)
这时辰须要我们加两个参数:./configure NOUVEAU_CFLAGS=disable NOUVEAU_LIBS=disable (反正我们只须要软件模仿)
从头configure,又呈现以下错误
configure: error: LLVM is required to build Gallium R300 on x86 and x86_64
sudo apt-get install llvm
总算经由过程了,太不轻易了!
8>.
configure: error: Package requirements (x11 xext xdamage xfixes x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8) were not met:
No package 'xcb-glx' found
No package 'xcb-dri2' found
sudo apt-get install libx11-xcb-dev libxcb-glx0 libxcb-glx0-dev
sudo apt-get install libxcb-dri2-0-dev
9>.
sudo apt-add-repository ppa:xorg-edgers
sudo apt-get update
sudo apt-get install libdrm-dev
10>.
xcb依赖
- sudo apt-get install libx11-xcb-dev
- sudo apt-get install libxcb-icccm4-dev (因为qtbase\config.tests\qpa\xcb中xcb/xcb_icccm.h)
- sudo apt-get install libxcb-xfixes0-dev(因为qtbase\config.tests\qpa\xcb中xcb/xfixes.h)
- sudo apt-get install libxcb-image0-dev(因为qtbase\config.tests\qpa\xcb中xcb/xcb_image.h)
- sudo apt-get install libxcb-keysyms1-dev(因为qtbase\config.tests\qpa\xcb中xcb/xcb_keysyms.h)
- sudo apt-get install libxcb-sync0-dev(因为qtbase\config.tests\qpa\xcb中xcb/sync.h)
- sudo apt-get install libxcb-render-util0-dev(因为qtbase\config.tests\qpa\xcb中xcb/xcb_renderutil.h)
opengl依赖
- sudo apt-get install libegl1-mesa-dev
- sudo apt-get install libgles1-mesa-dev
- sudo apt-get install libgles2-mesa-dev
11->
sudo apt-get install autoconf
sudo apt-get install libtool
./configure ok
执行make and make install 安装到默认路径include,lib文件是 /usr/local/include和/usr/local/lib下
步骤4:Configure OK, 然后单击Generate button,等待Projects生成完全。
7.至此,打开Code::Blocks IDE,导入刚才生成的工程文件:VTK.cbp。然后 就可以rebuild,等待半小时左右,就可以得到到lib。
编译build target:install后,会生成/usr/local/lib/vtk-5.10下 so 文件。
8.测试vtk是否安装完全成功:
在python2.7 IDE 上 输入import vtk,如果出现下面错误提示:
importError libvtkCommonPythonD.so.5.10:cannot open shared object file: No such file or directory
需要在命令行窗口中执行如下命令去修复错误:
ldconfig /usr/local/lib/vtk-5.10
9. eclipse pydev 添加对vtk 的 fold path:/usr/local/lib/python2.7/dist-packages/vtk
现在 vtk 可以正常运行了。