简体   繁体   中英

Cmake can't find Qt OpenGL library

I'm trying to compile a project using cmake . The instructions given to me was that Qt 4.8 is needed. Downloaded it from qt-project.org/downloads . Compiled and installed 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:

(...)

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?

This is confusing me, shouldn't the OpenGL library be installed?

It's not complaining about OpenGL. It's complainting about Qt's OpenGL module QtOpenGL which is a different thing. Most likely your custom build of Qt doesn't include the QtOpenGL module. You've to go back building Qt and take extra care that you enable build of the QtOpenGL module.

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. I just naturally ran "configure" without any options and hoped for the best.

./configure --help

Specifies that I needed -multimedia and -opengl . When I executed configure with the correct options the issue was resolved.

./configure -multimedia -opengl

Note that the multimedia kit needs gstreamer installed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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