现在的位置: 首页 > 综合 > 正文

用 Mingw 编译 VTK 5.0.4

2013年10月28日 ⁄ 综合 ⁄ 共 1756字 ⁄ 字号 评论关闭
 

最近开始关注 Visualization,尝试用 Mingw 编译 VTK,下面写点手记吧。

Mingw GCC版本:gcc (GCC) 3.4.2 (mingw-special)

编译步骤:

1. Install CMake

2. configure

    用 CMakeSetup 设置好源码和目标路径,configure 一下。完成后,设置相应的编译选项后,

点击 OK,即可生成所需的 Makefile。

3. make

编译错误及解决方法:

(1) vtkjpeg 的 boolean 类型冲突

[ 60%] Built target vtkjpeg
[ 60%] Building C object Utilities/vtktiff/CMakeFiles/vtktiff.dir/tif_jpeg.obj  In file included from C:/DOCUME~1/Usuario/Desktop/wrapper/VTK-50~1.4/VTK/UTILIT~1/vtkjpeg/jpeglib.h:27,
                 from C:/DOCUME~1/Usuario/Desktop/wrapper/VTK-50~1.4/VTK/UTILIT~1/vtk_jpeg.h:35,
                 from C:Documents and SettingsUsuarioDesktopwrappervtk-5.0.4VTKUtilitiesvtktifftif_jpeg.c:52:
C:/DOCUME~1/Usuario/Desktop/wrapper/VTK-50~1.4/VTK/UTILIT~1/vtkjpeg/jmorecfg.h:247: error: conflicting types for 'boolean'
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/rpcndr.h:52: error: previous declaration of 'boolean' was here
mingw32-make[2]: *** [Utilities/vtktiff/CMakeFiles/vtktiff.dir/tif_jpeg.obj] Error 1
mingw32-make[1]: *** [Utilities/vtktiff/CMakeFiles/vtktiff.dir/all] Error 2
mingw32-make: *** [all] Error 2


解决方法:

将 "VTK/Utilities/vtkjpeg/jconfig.h" 中的

#if defined(_WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__))
/* Define "boolean" as unsigned char, not int, per Windows custom */
/* don't conflict if rpcndr.h already read; Note that the w32api headers
   used by Cygwin and Mingw do not define "boolean", so jmorecfg.h
   handles it later. 
*/

#ifndef __RPCNDR_H__
typedef unsigned 
char boolean;
#endif
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
#endif

替换为

#if defined(_WIN32) || defined(__CYGWIN__)
/* typedef "boolean" as unsigned char to match rpcndr.h */
typedef unsigned 
char boolean;
#define HAVE_BOOLEAN /* prevent jmorecfg.h from typedef-ing it as int */
#endif


抱歉!评论已关闭.