[Solved] Building 32-bit app under 64-bit Ubuntu - Cannot find -lGL ( OpenGL) even though added to lib path ?



    • I have both 32 and 64 bit Qt 5.3.1 installed under Ubuntu 64-bit.
    • I can build a 64-bit Qt app no problems
    • I installed 32-bit mesa and many other dependencies in order to install 32-bit Qt
    • I added "-m32" and GL lib path to qmake project file
    • 32-bit Qt apps compile but cannot link with GL
    • The following link error occurs when building for Desktop Qt 5.3 GCC 32bit:
      @
      /usr/bin/ld: cannot find -lGL
      @

    Is this a lib path order problem? What am I not seeing?

    File: Qt Project
    @
    QT += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = trash-widget
    TEMPLATE = app

    Ubuntu x64: x86_64

    message(QMAKE_HOST.arch = $$QMAKE_HOST.arch)

    GCC 32-bi: i386

    GCC 64-bit: x86_64

    message(QT_ARCH = $${QT_ARCH})

    equals(QT_ARCH, "i386") {
    TARGET = $${TARGET}x32
    QMAKE_CXXFLAGS += -m32

    # GL was installed here:
    # /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2.0
    LIBS += -L/usr/lib/i386-linux-gnu/mesa
    

    } equals(QT_ARCH, "x86_64") {
    TARGET = $${TARGET}x64
    }

    SOURCES += main.cpp
    mainwindow.cpp
    HEADERS += mainwindow.h
    FORMS += mainwindow.ui
    @

    Compiler Output: "/usr/bin/ld: cannot find -lGL"
    @
    g++ -m32 -Wl,-rpath,/opt/Qt5.3.1-x32/5.3/gcc -Wl,-rpath,/opt/Qt5.3.1-x32/5.3/gcc/lib -o trash-widgetx32 main.o mainwindow.o moc_mainwindow.o -L/usr/lib/i386-linux-gnu/mesa -L/opt/Qt5.3.1-x32/5.3/gcc/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread
    /usr/bin/ld: cannot find -lGL
    collect2: error: ld returned 1 exit status
    make: *** [trash-widgetx32] Error 1
    14:25:03: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project trash-widget (kit: Desktop Qt 5.3 GCC 32bit)
    When executing step 'Make'
    14:25:03: Elapsed time: 00:03.
    @

    Thanks in advance,

    -Ed


  • Lifetime Qt Champion

    Hi,

    Did you install the OpenGL dev package ?



  • Thank you! That was it. I can now build either 32 or 64 bit Qt apps.

    I installed these two packages. I am not sure if I needed mesa-common-dev but once I installed libglu1-mesa-dev:i386 all was good!
    @
    sudo apt-get install mesa-common-dev:i386
    sudo apt-get install libglu1-mesa-dev:i386
    @

    I had them in my development environment notes but somehow missed installing. I need to make a script or a kickstart.

    Thanks again,

    -Ed



  • Under Ubuntu 14.04 64-bit,

    I added these packages in order to install Qt 5.3.1 32-bit and build 32-bit apps under 64-bit Ubuntu.

    @
    sudo apt-get install \

    Qt: deps \

    libsm6:i386
    libxrender1:i386
    libfontconfig1:i386
    libxext6:i386
    libgtk2.0-0:i386
    libcanberra-gtk-module:i386
    libxslt1.1:i386
    libglu1-mesa-dev:i386
    libc6-i386
    libglib2.0-0:i386
    libsm6:i386
    libglu1-mesa:i386
    libgl1-mesa-glx:i386
    libxext6:i386
    libxrender1:i386
    libx11-6:i386
    libfontconfig1:i386
    lsb-core
    g++-multilib \

    Qt Creator Deps: \

    libgstreamer0.10-0:i386
    libgstreamer-plugins-base0.10-0:i386

    Install 32-bit Qt:
    chmod +x qt-opensource-linux-x86-android-5.3.1.run
    ./qt-opensource-linux-x86-android-5.3.1.run
    @

    I used sudo to run the Qt installers and installed each Qt to it's own folder:

    • /opt/Qt5.3.1-x32
    • /opt/Qt5.3.1-x64

    Then I launched 64-bit Qt Creator and configures a 32 bit Qt version, then cloned the 64-bit build kit and renamed it to 32-bit and made it point to the 32bit Qt version.

    I suspect there may be better solutions to install 32 and 64 bit Qt that do not use as much disk space but this approach works and does not make my brain hurt too much. ;-)

    -Ed



  • Apparently OpenGL 32 and 64 bit packages remove and replace each other under 64-bit Ubuntu and last package installed wins.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.