Cmake找不到Qt OpenGL库

时间:2013-12-19 09:37:40

标签: qt opengl qt4 cmake

我正在尝试使用cmake编译项目。给我的指示是需要Qt 4.8。从qt-project.org/downloads下载。编译并安装了Qt 4.8:

mazdak@lnxamindai> qmake -query   
QT_INSTALL_PREFIX:/usr/local/Trolltech/Qt-4.8.5
QT_INSTALL_DATA:/usr/local/Trolltech/Qt-4.8.5
QT_INSTALL_DOCS:/usr/local/Trolltech/Qt-4.8.5/doc
QT_INSTALL_HEADERS:/usr/local/Trolltech/Qt-4.8.5/include
QT_INSTALL_LIBS:/usr/local/Trolltech/Qt-4.8.5/lib
QT_INSTALL_BINS:/usr/local/Trolltech/Qt-4.8.5/bin
QT_INSTALL_PLUGINS:/usr/local/Trolltech/Qt-4.8.5/plugins
QT_INSTALL_IMPORTS:/usr/local/Trolltech/Qt-4.8.5/imports
QT_INSTALL_TRANSLATIONS:/usr/local/Trolltech/Qt-4.8.5/translations
QT_INSTALL_CONFIGURATION:/etc/xdg
QT_INSTALL_EXAMPLES:/usr/local/Trolltech/Qt-4.8.5/examples
QT_INSTALL_DEMOS:/usr/local/Trolltech/Qt-4.8.5/demos
QMAKE_MKSPECS:/usr/local/Trolltech/Qt-4.8.5/mkspecs
QMAKE_VERSION:2.01a
QT_VERSION:4.8.5

但是,在编译项目时,我收到以下错误:

root@lnxamindai> cmake .    
    -- Setting flags for GNU GCC
    -- REQUIRED_VARS  (missing:  QTMOBILITY_INCLUDE_DIR QTMOBILITY_MULTIMEDIAKIT_INCLUDE_DIR QTMOBILITY_MULTIMEDIAKIT_LIBRARY VERSION_VAR QTMOBILITY_VERSION)
    Qt QTOPENGL library not found.
    -- Buiding ManyEarsLib Library...
    -- Buiding RTAudio Library...
    -- Found jack: /usr/lib/libjack.so
    ALSA lib : -lasound -lpthread
    Qt QTOPENGL library not found.
    CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
    Please set them or make sure they are set and tested correctly in the CMake files:
    OPENGL_INCLUDE_DIR (ADVANCED)
       used as include directory in directory /home/mazdak/dev/ManyEars/manyears/QtGUI
    QTMOBILITY_MULTIMEDIAKIT_LIBRARY (ADVANCED)
        linked by target "ManyEars" in directory /home/mazdak/dev/ManyEars/manyears/QtGUI

    -- Configuring incomplete, errors occurred!

的CMakeLists.txt:

(...)

IF (NOT MANYEARS_GUI_DISABLED)

    SET(QT_USE_QTNETWORK TRUE)
    SET(QT_USE_QTSVG TRUE)
    SET(QT_USE_QTXML TRUE)
    SET(QT_USE_QTSCRIPT TRUE)
    SET(QT_USE_QTOPENGL TRUE)
    SET(QT_USE_QTMULTIMEDIA TRUE)

    find_package(QtMobility COMPONENTS MultimediaKit)
    find_package(Qt4 4.8.0 QUIET)

    if (QTMOBILITY_FOUND)
        MESSAGE("QT_MOBILITY_INCLUDE_DIR : ${QTMOBILITY_INCLUDE_DIRS} QT_MOBILITY_LIB: ${QTMOBILITY_LIBRARIES}")
    ENDIF (QTMOBILITY_FOUND)


    if(QT4_FOUND AND (QT_QTMULTIMEDIA_FOUND OR QTMOBILITY_FOUND))
    include(${QT_USE_FILE})
    else(QT4_FOUND AND (QT_QTMULTIMEDIA_FOUND OR QTMOBILITY_FOUND))
        MESSAGE("WARNING : ManyEars GUI will not be compiled because Qt4 not found or obsolete. You need Qt 4.8 or higher.Try using the latest QtSDK from http://qt-project.org")
        MESSAGE("DEBUG: QT4_FOUND: ${QT4_FOUND} QT_MULTIMEDIA_FOUND: ${QT_QTMULTIMEDIA_FOUND}  QT_MOBILITY_FOUND: ${QTMOBILITY_FOUND}")
        SET(MANYEARS_GUI_DISABLED TRUE)
    endif(QT4_FOUND AND (QT_QTMULTIMEDIA_FOUND OR QTMOBILITY_FOUND))

ELSE (NOT MANYEARS_GUI_DISABLED)
    MESSAGE("ManyEars GUI disabled.")
ENDIF (NOT MANYEARS_GUI_DISABLED)


#Files excluded from package
set(CPACK_SOURCE_IGNORE_FILES
  "build"
  "bin"
  ${CPACK_SOURCE_IGNORE_FILES}
  ".svn"
)



#include files
(...)

IF (UNIX)

        #########################################
        # Packaging stuff for sources (All UNIX)
        #########################################
        SET(CPACK_SOURCE_GENERATOR "TGZ")
            SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING.TXT")
        SET(CPACK_PACKAGE_NAME "ManyEars")
        SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "ManyEars")
        SET(CPACK_PACKAGE_VENDOR "Francois Grondin, Dominic Letourneau")
            SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.TXT")
        SET(CPACK_PACKAGE_CONTACT "blablablabla")


    (...)

ENDIF(UNIX)

(...)

INCLUDE(CPack)

这让我很困惑,不应该安装OpenGL库吗?

2 个答案:

答案 0 :(得分:2)

  

这让我很困惑,不应该安装OpenGL库吗?

这并不是在抱怨OpenGL。它抱怨Qt的OpenGL模块QtOpenGL是另一回事。很可能你的Qt自定义版本不包括QtOpenGL模块。您需要重新构建Qt并特别注意启用QtOpenGL模块的构建。

答案 1 :(得分:0)

经过一番研究后,我发现I needed to install some development packages if I was compiling from the source code

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

配置Qt源代码时,我忘了指定我要安装OpenGL模块和多媒体套件。我只是自然地在没有任何选项的情况下运行“配置”并希望最好。

./configure --help

指定我需要-multimedia-opengl。 当我使用正确的选项执行configure时,问题已得到解决。

./configure -multimedia -opengl

请注意,多媒体套件需要安装gstreamer。