Important: Please read the Qt Code of Conduct -

OpenGLES test project on Android fails to compile

  • I did all the configuration steps and provided every directory for jdk, sdk, ant & android ndk.
    I'm trying now to compile a simple test project which builds and run fine while compiling it with the desktop compiler but fails on armv7 since "error: No such file or directory"

    extended error:

    23:25:11: Running steps for project OpenGL_ES2...
    23:25:11: Configuration unchanged, skipping qmake step.
    23:25:11: Starting: "D:\Qt\Tools\mingw492_32\bin\mingw32-make.exe" 
    D:\Android\android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -g -g -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\OpenGL_ES2 -I. -ID:\Qt\5.5\android_armv7\include -ID:\Qt\5.5\android_armv7\include\QtOpenGL -ID:\Qt\5.5\android_armv7\include\QtWidgets -ID:\Qt\5.5\android_armv7\include\QtGui -ID:\Qt\5.5\android_armv7\include\QtCore -I. -isystem D:\Android\android-ndk-r10e\sources\cxx-stl\gnu-libstdc++\4.9\include -isystem D:\Android\android-ndk-r10e\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a\include -isystem D:\Android\android-ndk-r10e\platforms\android-9\arch-arm\usr\include -ID:\Qt\5.5\android_armv7\mkspecs\android-g++ -o controller.obj ..\OpenGL_ES2\controller.cpp
    In file included from ..\OpenGL_ES2\controller.cpp:1:0:
    ..\OpenGL_ES2\controller.h: In constructor 'MainWindow::MainWindow(QWindow*)':
    ..\OpenGL_ES2\controller.h:36:21: warning: 'MainWindow::m_context' will be initialized after [-Wreorder]
         QOpenGLContext *m_context;
    ..\OpenGL_ES2\controller.h:35:21: warning:   'QSurfaceFormat* MainWindow::fmt' [-Wreorder]
         QSurfaceFormat *fmt;
    ..\OpenGL_ES2\controller.cpp:3:1: warning:   when initialized here [-Wreorder]
     MainWindow::MainWindow(QWindow *parent) : QWindow(parent),
    D:\Android\android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++ --sysroot=D:\Android\android-ndk-r10e/platforms/android-9/arch-arm/ -Wl,-soname,"libAndroid" -Wl,--no-undefined -Wl,-z,noexecstack -shared -o libAndroid main.obj controller.obj moc_controller.obj   -LD:\Android\android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a -LD:\Android\android-ndk-r10e/platforms/android-9/arch-arm//usr/lib -LD:/Qt/5.5/android_armv7/lib -lQt5OpenGL -Lc:\utils\android\ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a -Lc:\utils\android\ndk/platforms/android-9/arch-arm//usr/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lgnustl_shared -llog -lz -lm -ldl -lc -lgcc
    arm-linux-androideabi-g++: error: No such file or directory
    makefile:83: recipe for target 'libAndroid' failed
    mingw32-make: *** [libAndroid] Error 1
    23:25:13: The process "D:\Qt\Tools\mingw492_32\bin\mingw32-make.exe" exited with code 2.
    Error while building/deploying project OpenGL_ES2 (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.5.1))
    When executing step "Make"
    23:25:13: Elapsed time: 00:02.

    here's the source.cpp:

    #include "controller.h"
    MainWindow::MainWindow(QWindow *parent) : QWindow(parent),
                                              fmt(new QSurfaceFormat)
        //I'll need later fmt to try and set an alpha buffer on it
        fmt = new QSurfaceFormat(requestedFormat());
        m_context = new QOpenGLContext(this);
    void MainWindow::render()
        if (!isExposed())  return;
        QTime t;
        t = QTime::currentTime();
        glClearColor(1, 0.5f, 0, 0.5f);
        QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));

    Lastly the .pro file:

    TEMPLATE = app
    TARGET = Android OpenGL
    QT += core gui opengl
    SOURCES += \
        main.cpp \
    HEADERS += \
    CONFIG += mobility

    Unfortunately this is the first time I try to build a project targeted for android and it all seems fine while compiling for desktop but it crashes on arm7
    Is something missing in the ndk? I don't even know where i'm supposed to place the missing nor how to compile it

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    I'd remove the space between Android and OpenGL in your TARGET directive.

  • Awkward moment of the day I guess

    Quick unrelated question: Is it possible to have a format that can make the opengl application's background transparent?

    in the desktop it's sufficient to use :
    for the desired effect

    Anyway, thanks a lot for your help

    EDIT: nevermind, I solved it. you only need to change the manifest and apply android:theme="@android:style/Theme.Translucent" to the application tag

  • Lifetime Qt Champion

    Glad you found out and thanks for sharing !

    Since you have it working now please mark the thread as solved using the"Topic Tool" button so that other forum users may know a solution has been found :)