0 开发环境
计算机系统:Win8.1,CPU:i5-5200
1 VTKData、VTKLargeData
详见《VTK编译安装 —— VTKData和VTKLargeData使用说明(一)》、《VTK编译安装 —— VTKData和VTKLargeData使用说明(二)》。
2 OpenGL
一开始时,使用qt-opensource-windows-x86-msvc2012_64-5.2.1.exe,编译失败。后来发现需要OpenGL的支持,改用qt-opensource-windows-x86-msvc2012_64_opengl-5.2.1.exe就好!
关于Qt的支持,见参考资料[1]。
3 CMAKE_PREFIX_PATH
在参考资料[1]中提示,使用cmake对VTK进行配置时,需要添加CMAKE_PREFIX_PATH,由于不知其作用,并且觉没有这个必要,因此没有添加,结果编译阶段提示错误:
-- Configuring incomplete, errors occurred!
127> See also "D:/VTK/build_Qt/CMakeFiles/CMakeOutput.log".
127> See also "D:/VTK/build_Qt/CMakeFiles/CMakeError.log".
129> CMake Error at GUISupport/Qt/CMakeLists.txt:58 (find_package):
129> By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
129> has asked CMake to find a package configuration file provided by
129> "Qt5Widgets", but CMake did not find one.
129>
129> Could not find a package configuration file provided by "Qt5Widgets" with
129> any of the following names:
129>
129> Qt5WidgetsConfig.cmake
129> qt5widgets-config.cmake
129>
129> Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
129> "Qt5Widgets_DIR" to a directory containing one of the above files. If
129> "Qt5Widgets" provides a separate development package or SDK, be sure it has
129> been installed.
再次使用cmake配置时,也提示
CMake Error at GUISupport/Qt/CMakeLists.txt:58 (find_package):
By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Qt5Widgets", but CMake did not find one.
Could not find a package configuration file provided by "Qt5Widgets" with
any of the following names:
Qt5WidgetsConfig.cmake
qt5widgets-config.cmake
Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
"Qt5Widgets_DIR" to a directory containing one of the above files. If
"Qt5Widgets" provides a separate development package or SDK, be sure it has
been installed.
看来,不添加是不行的了,因此按照参考资料[1]的方法,点击cmake界面坐上角的“Add Entry”按钮,添加CMAKE_PREFIX_PATH选项
注意:另外一个解决方法就是,将Qt库的路径添加到系统环境变量PATH中即可,见《VS2013编译安装VTK-6.2.0_支持Qt5.4.2》。
4 Qt5Gui_glu32_LIBRAYRY
解决了第3章的问题后,配置过程中又出现了新问题:
CMake Error at C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:16 (message):
Failed to find "glu32" in "" with CMAKE_CXX_LIBRARY_ARCHITECTURE "".
Call Stack (most recent call first):
C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:52 (_qt5gui_find_extra_libs)
C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:152 (include)
C:/Qt/Qt5.2.1/5.2.1/msvc2012_64_opengl/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:94 (find_package)
GUISupport/Qt/CMakeLists.txt:58 (find_package)
根据参考资料[2]的提示,需添加CMAKE_PREFIX_PATH(第3章中已经将此项的值设为Qt的安装路径)的值:
C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64
照着参考资料[2]的方法设置后,发现第4章的问题是解决了,但是第3章的问题又出现了!
于是将CMAKE_PREFIX_PATH的值同时设为第3章设置的值和C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64,两者之间用分号隔开(就像环境变量Path中各个变量的分隔一样)。
其实根据参考资料[2]的提示,可以将第3章的值设置为环境变量Path的值即可,无需都在CMAKE_PREFIX_PATH中设置(未经测试)。
因此可以猜测CMAKE_PREFIX_PATH指定的是库的路径,相当于环境变量的作用。
参考资料
[5]MSVC2012+QT5.2.1+VTK6.1+win8
[7]Solution to Failed to find "glu32" in "" with CMAKE_CXX_LIBRARY_ARCHITECTURE ""