1. 编译环境
- JDK(11,可选);
- Python(3.7,可选);
- QT(MinGW,5.13.2,默认支持源码调试);
- CMake(3.14);
- VTK(8.2.0);
2. 编译配置(CMake)
CMAKE_BUILD_TYPE release
CMAKE_INSTALL_PREFIX C:/VTK/vtk-8.2.0
VTK_GROUP_Qt YES
Qt5_DIR C:\Qt\Qt5.13.2\5.13.2\mingw73_64\lib\cmake\Qt5
3. 编译安装
# 编译源码;
PS: C:\VTK\build> mingw32-make.exe -j4
# 安装程序;
PS: C:\VTK\build> mingw32-make.exe install
4. 错误处理
4.1 编译错误(File too big / too many sections)
解决方法:
C:\OpenCV\VTK-8.2.0\CMakeList.txt,增加编译优化选项;
add_definitions(-BigObj) ## 本选项可以解决问题,若无效增加如下选项;
add_definitions(-Ofast -flto) ## 本选项为选填内容,上午选项无效时开启;
4.2 编译错误(glew.c,undefined reference to ‘memset’)
解决方法:
C:\OpenCV\VTK-8.2.0-build\ThirdParty\glew\vtkglew\CMakeFiles\vtkglew.dir\flags.make,增加编译选项(-minline-all-stringops);
C_FLAGS = -mwin32 -mthreads -w -w -O3 -DNDEBUG -BigObj -minline-all-stringops
4.3 编译错误(SQLite will not work correctly with the -ffast-math option of GCC)
错误来源:
CMakeList.txt文件中,全局增加了add_definitions(-Ofast -flto)优化选项所致;
解决方法:
C:\OpenCV\VTK-8.2.0-build\ThirdParty\sqlite\vtksqlite\CMakeFiles\vtksqlite.dir\flags.make,修改编译选项去掉(-Ofast -flto);
C_FLAGS = -mwin32 -mthreads -w -w -O3 -DNDEBUG
附加说明,若依然无效,可将O3优化降级为O2,因为某修编译器的O3优化,会默认使用-ffast-math;
注:确保路径“C:\VTK\VTK-8.2.0-release\bin”和“C:\VTK\VTK-8.2.0-debug\bin”,已经添加到系统环境变量$PATH。