简体   繁体   English

Cmake找不到Qt OpenGL库

[英]Cmake can't find Qt OpenGL library

I'm trying to compile a project using cmake . 我正在尝试使用cmake编译项目。 The instructions given to me was that Qt 4.8 is needed. 给我的指示是需要Qt 4.8。 Downloaded it from qt-project.org/downloads . qt-project.org/downloads下载了它。 Compiled and installed Qt 4.8: 编译并安装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

However, when compiling the project I received the following error: 但是,在编译项目时,我收到以下错误:

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: 的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)

This is confusing me, shouldn't the OpenGL library be installed? 这让我很困惑,不应该安装OpenGL库吗?

This is confusing me, shouldn't the OpenGL library be installed? 这让我很困惑,不应该安装OpenGL库吗?

It's not complaining about OpenGL. 它并没有抱怨OpenGL。 It's complainting about Qt's OpenGL module QtOpenGL which is a different thing. 它抱怨Qt的OpenGL模块QtOpenGL是另一回事。 Most likely your custom build of Qt doesn't include the QtOpenGL module. 很可能你的Qt自定义版本不包括QtOpenGL模块。 You've to go back building Qt and take extra care that you enable build of the QtOpenGL module. 您需要重新构建Qt并特别注意启用QtOpenGL模块的构建。

After some research I found out that 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

When configuring the Qt source code I had forgot to specify that I wanted to install the OpenGL module and the Multimedia Kit. 在配置Qt源代码时,我忘了指定我要安装OpenGL模块和多媒体套件。 I just naturally ran "configure" without any options and hoped for the best. 我只是自然地运行“配置”没有任何选项,并希望最好的。

./configure --help

Specifies that I needed -multimedia and -opengl . 指定我需要-multimedia-opengl When I executed configure with the correct options the issue was resolved. 当我使用正确的选项执行configure时,问题已得到解决。

./configure -multimedia -opengl

Note that the multimedia kit needs gstreamer installed. 请注意,多媒体套件需要安装gstreamer。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM