![应该如何安装 QtOpenGL 才能使 cmake 能够找到它?](https://linux22.com/image/1090278/%E5%BA%94%E8%AF%A5%E5%A6%82%E4%BD%95%E5%AE%89%E8%A3%85%20QtOpenGL%20%E6%89%8D%E8%83%BD%E4%BD%BF%20cmake%20%E8%83%BD%E5%A4%9F%E6%89%BE%E5%88%B0%E5%AE%83%EF%BC%9F.png)
我有这个问题尝试从源安装 Extcalc 时:
ezio@Cantabury ~/Downloads/extcalc-0.9.3-1 $ cmake .
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found.
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found.
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found.
-- Found Qt-Version 4.8.7 (using /usr/bin/qmake)
Qt QTOPENGL library not found.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ezio/Downloads/extcalc-0.9.3-1
解决方案是“重新构建 Qt,并特别注意启用 QtOpenGL 模块的构建”。问题是我通过 apt-get 安装了所有东西,包括 Qt,我想我还安装了 QtOpenGl。具体来说,在尝试让它工作的过程中,我安装了这些软件包(除了系统上已有的一些其他核心 Qt 模块):
libqt4-opengl, python-qt4-gl, build-essential, qt4-dev-tools, libqt4-dev
以及 Mazze 建议的软件包列表:
apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libx11-xcb-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev
我在网上找不到任何其他有关安装 QtOpenGl(没有整个 Qt 包)的资源。
- 我如何检查我是否确实安装了此模块?
- 如果有的话,我怎样才能让 cmake 找到它?
- 如果没有,最简单的安装方法是什么?
以下是我认为可能相关的 CMakeList.txt 部分。剪切部分由 [...] 表示。
PROJECT(extcalc)
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.3 FATAL_ERROR)
if(POLICY CMP0005)
cmake_policy(SET CMP0005 OLD)
endif(POLICY CMP0005)
FIND_PACKAGE(Qt4 REQUIRED)
ADD_DEFINITIONS(-DQT3_SUPPORT)
SET( CMAKE_BUILD_TYPE Release )
SET( QT_USE_QT3SUPPORT TRUE )
SET( QT_USE_QTOPENGL TRUE )
SET( QT_USE_QTGUI TRUE )
INCLUDE(${QT_USE_FILE})
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}
${QT_INCLUDE_PATH}
src/
.)
SET(CPACK_INSTALL_CMAKE_PROJECTS "/home/user/Projekte/extcalc;Extcalc;ALL;/")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Scientific Graphic Calculator")
SET(CPACK_PACKAGE_VENDOR "")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_VERSION "0.9.3")
SET(CPACK_PACKAGE_NAME "extcalc")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
SET(CPACK_STRIP_FILES "bin/extcalc")
SET(CPACK_SOURCE_STRIP_FILES "")
SET(CPACK_PACKAGE_EXECUTABLES "extcalc;extcalc")
SET(CPACK_GENERATOR "TGZ")
SET(CPACK_SOURCE_GENERATOR "TGZ")
SET(CPACK_SOURCE_IGNORE_FILES "CVS/")
#Debian speciefic
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 , libgcc1, libgl1-mesa-glx | libgl1, libglu1-mesa | libglu1, libqtcore4, libqt4-qt3support , libstdc++6, libx11-6, libxext6, libxft2")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Rainer Strobel <[email protected]>")
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Extcalc is a multifunctional scientific graphic calculator for Linux with features like graph drawing, graph analysis and calculation of scientific functions. Extcalc also provides an integrated programming language.")
SET(CPACK_DEBIAN_PACKAGE_SECTION "math")
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
SET(CPACK_RPM_PACKAGE_ARCHITECTURE "i386")
SET(CPACK_RPM_PACKAGE_LICENSE "GPL")
SET(CPACK_RPM_PACKAGE_GROUP "Productivity/Schientific/Math")
SET(CPACK_RPM_PACKAGE_VENDOR "Rainer Strobel <[email protected]>")
SET(CPACK_RPM_PACKAGE_DESCRIPTION "Extcalc is a multifunctional scientific graphic calculator for Linux with features like graph drawing, graph analysis and calculation of scientific functions. Extcalc also provides an integrated programming language.")
INCLUDE(CPack)
SET([...]
)
QT4_ADD_RESOURCES(qrc_cxx ${src_qrc})
QT4_WRAP_CPP(moc_cxx ${moc_h})
QT4_WRAP_UI(ui_h ${src_ui})
SET(CMAKE_INSTALL_PREFIX "/usr/local")
SET(SHAREDIR "share/extcalc/data")
SET(DOCDIR "share/extcalc/doc")
SET(DESKTOPDIR "share/applications")
SET(ICONDIR "share/icons")
SET(MANDIR "/usr/man")
SET(BINDIR "bin")
ADD_DEFINITIONS(-DINSTALLDIR=\"\\\"${CMAKE_INSTALL_PREFIX}/share/extcalc\\\"\")
#installer data
INSTALL(FILES
[...]
)
ADD_EXECUTABLE(extcalc WIN32 ${src_cxx} ${src_h} ${moc_cxx} ${moc_ui_cxx} ${src_ui_cxx} ${ui_h} ${qrc_cxx})
TARGET_LINK_LIBRARIES(extcalc ${QT_LIBRARIES})
INSTALL(TARGETS extcalc RUNTIME DESTINATION bin
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_READ
WORLD_EXECUTE WORLD_READ)