[HowTo] Cross compile Qt5

Started by Cosik, October 27, 2014, 11:17:52 AM

Previous topic - Next topic

sajmon5544

#30
Hi guys.

I've managed to build Qt5 library (5.4.1) on A20 Lime2 board.
I'm using A20-OLinuXino-Lime Debian with kernel 3.4.90+ release 3 system.

When I try to run any qml app (bin/qml app in the qt instalation dir) i get
Could not initialize egl display
Aborted


I'm sure I'm missing something.

Thanks for great tutorial.

@EDIT
Ok, I had X11 mali driver version, instead of framebuffer one.

Cosik

#31
Quote from: sajmon5544 on March 17, 2015, 02:43:44 PM
Ok, I had X11 mali driver version, instead of framebuffer one.

So if you want to use X11 drivers instead of framebuffer you should compile mali drivers with proper option.

Here you have information how to do it http://linux-sunxi.org/Mali_binary_driver

Kafanti

Hey Cosik,

Thanks for your guide. I followed it but I got compilation errors on building phase. I guess it is not possible to understand exact reason but maybe you might have an idea.

I am trying to compile qtbase first, here it is my configurations:

./configure -v -opengl es2 -device linux-sunxi-g++ -device-option CROSS_COMPILE=~/opt/gcc-linaro-arm-linux-gnueabihf-2012.09-20120921_linux/bin/arm-linux-gnueabihf- -sysroot /mnt/rootfs -opensource -confirm-license -qt-zlib -qt-xcb -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5ox 2>&1 | tee "confout21agu201209.txt"

And after configuration phase, when I start to compile it here is my logs when it fails,

arm-linux-gnueabihf-g++ -c -pipe -I /mnt/lime-rootfs/usr/include -I /mnt/lime-rootfs/usr/include/arm-linux-gnueabihf -marm -march=armv7-a -mtune=cortex-a8 -mfloat-abi=hard --sysroot=/mnt/lime-rootfs -g -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -std=c++0x -fno-exceptions -Wall -W -D_REENTRANT -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_XKB -DQT_NO_CAST_FROM_ASCII -DMESA_EGL_NO_X11_HEADERS -DQT_NO_FONTCONFIG -DFT2_BUILD_LIBRARY -DQT_BUILD_PLATFORMSUPPORT_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_GUI_LIB -DQT_DBUS_LIB -DQT_CORE_LIB -I. -I../3rdparty/freetype/builds/unix -I../3rdparty/freetype/src -I../3rdparty/freetype/include -Iaccessibility -I../3rdparty/atspi2 -Ilinuxaccessibility -I../../include -I../../include/QtPlatformSupport -I../../include/QtPlatformSupport/5.4.2 -I../../include/QtPlatformSupport/5.4.2/QtPlatformSupport -I../../include/QtCore/5.4.2 -I../../include/QtCore/5.4.2/QtCore -I../../include/QtGui/5.4.2 -I../../include/QtGui/5.4.2/QtGui -I../../include/QtGui -I../../include/QtDBus -I../../include/QtCore -I.moc -I../../mkspecs/devices/linux-sunxi-g++ -o .obj/qeglplatformcursor.o eglconvenience/qeglplatformcursor.cpp
eglconvenience/qeglplatformcursor.cpp: In member function 'bool QEGLPlatformCursor::setCurrentCursor(QCursor*)':
eglconvenience/qeglplatformcursor.cpp:234:15: error: expected unqualified-id before numeric constant
eglconvenience/qeglplatformcursor.cpp:235:27: error: 'newShape' was not declared in this scope
eglconvenience/qeglplatformcursor.cpp:242:22: error: 'newShape' was not declared in this scope
Makefile:4370: recipe for target '.obj/qeglplatformcursor.o' failed
make[3]: *** [.obj/qeglplatformcursor.o] Error 1
make[3]: Leaving directory '/home/sina/qt-src/qt-everywhere-opensource-src-5.4.2/qtbase/src/platformsupport'
Makefile:473: recipe for target 'sub-platformsupport-make_first' failed
make[2]: *** [sub-platformsupport-make_first] Error 2
make[2]: Leaving directory '/home/sina/qt-src/qt-everywhere-opensource-src-5.4.2/qtbase/src'
Makefile:45: recipe for target 'sub-src-make_first' failed
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory '/home/sina/qt-src/qt-everywhere-opensource-src-5.4.2/qtbase'
Makefile:60: recipe for target 'module-qtbase-make_first' failed
make: *** [module-qtbase-make_first] Error 2


I am not sure what is it matter, but maybe dependency issue :S ?

Btw here is the line 234,

const Qt::CursorShape newShape = cursor ? cursor->shape() : Qt::ArrowCursor;

Thanks,
Sina




Cosik

Hi Sina,

It's very old topic, I didn't cross compile Qt from that time frame, but I will try to help you.

I think that I had some similar problem but I didn't remember solution, but try to deduce.

First thing, how many times did you cross compile Qt on this sources?

Kafanti

Hey Cosik,

Atleast I am happy I am not the only one who has that error :).

And as an answer to your question, I do always remove the whole qt source tree and untar again. So I do always work with a clean source codes.

First I just thought that might be a problem because of my crosstoolchain but I have tried the different one but the result is same. Also I have tried native compilation on the board but result is the same :S.

I am suspecting if an header file with symbolic constants have same name with an identifier might change the source code which comes from the board headers, but could not be able to find it out.

If you would be able to remember your solution I would be really heppy :).

Thank you Cosik,
Sina

Cosik

Ok, next steps:

Could you somehow include here yours Qt config file after configuration, and all output information from compilation?

Kafanti

Yes ofcourse, I was piping the whole stderr and stdout to .txt to check the process :)

here is the dropbox link to files, you can view them over this link,

https://www.dropbox.com/sh/rruds4py29h8at4/AAA8Y9CU5G0fCqLK0L92lJS3a?dl=0

Thank you,
Sina

Cosik

Question: do you need support for DBus?

If not please try to disable it during configuration and then try to compile sources.

Kafanti

Well, I guess I do not need DBus support.

And I just tried new clean build with -no-dbus option but same result :S

TCash

#39
Thanks for this great tutorial!

I have been able to successfully cross compile qt 5.5 with the LIME2.  I am using the 20140116-mali-r3p2-01rel2 branch off of ssvb's linux-sunxi kernal. (https://github.com/ssvb/linux-sunxi).  I also have patched qeglfshooks_stub.cpp with the file at the beginning of this thread before compiling Qt:
EGLNativeWindowType QEglFSHooks::createNativeWindow(QPlatformWindow *platformWindow,
                                                    const QSize &size,
                                                    const QSurfaceFormat &format)
{
    Q_UNUSED(platformWindow);
    Q_UNUSED(size);
    Q_UNUSED(format);
    //return 0;

    static struct mali_native_window native_window = {
        .width = (short unsigned int)size.width(),
        .height = (short unsigned int)size.height(),
    };
    return &native_window;
}


I have also run through the mali binary deployment by running through this guide: http://linux-sunxi.org/Mali_binary_driver.  So I have the mali libraries configured with EGL_TYPE=framebuffer using r3p2-01rel2 drivers.

However when running my qt apps I still get this error at runtime:
Could not create the egl surface: error = 0x300b

For my cross compiler I'm using arm-linux-gnueabihf-g++ 4.8


any ideas?  At the moment I'm trying to compile qt 5.3 instead to see if it makes a difference.
Our goal is to get qt working with egl on both frame-buffers.

Thanks!


UPDATE: I found I was overriding all of qeglfshooks.cpp with only the patched code and not actually editing the file internally this fixed the 0x300b error.  I should not that in Qt 5.5 instead of patching qeglfshooks.cpp, patching qtbase/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp. 

Cosik

Quote from: Kafanti on August 24, 2015, 10:57:23 AM
Well, I guess I do not need DBus support.

And I just tried new clean build with -no-dbus option but same result :S

Hi Kafanti,

I have no idea. I will try to compile source again, but my setup is in pieces and I have some other projects, what is more I just come back from vacation. I will try to inform you when I will have some results.

Sohaib Manzoor

Hi all

i am trying to build QT5 using this tutorial and i am able to completely build and install all Qt packages but when i try to compile the last command  i.e.  " make -j 5 && sudo make install " i get the following error at the end

../../../../include/QtCore/../../../qtbase-opensource-src-5.3.2/src/corelib/io/qurl.h:139:9: error: expected identifier before numeric constant
    ../../../../include/QtCore/../../../qtbase-opensource-src-5.3.2/src/corelib/io/qurl.h:139:9: error: expected '}' before numeric constant
    ../../../../include/QtCore/../../../qtbase-opensource-src-5.3.2/src/corelib/io/qurl.h:139:9: error: expected unqualified-id before numeric constant
    ../../../../include/QtCore/../../../qtbase-opensource-src-5.3.2/src/corelib/io/qurl.h:171:26: error: 'UrlFormattingOption' was not declared in this scope

Please I need some help here, because currently I'm stuck.. i have disabled d-bus and did everything from start, yet the results are same..


Here are my build environment details:

-Target system: arm-linux-gnueabihf

-OS: Ubuntu-14.04

-Build system: i386-linux

-Embedded machine: A20 olinuxino micro 4gb

Cosik

Hi Sohaib Manzoor,

Which processor do you have or how many cores do you have?

Please execute only make and then please show output.

Sohaib Manzoor

Hey Cosik, I'm using A20-4GB MICRO. This is my ./configure output:

Configure summary

Building on:   linux-g++ (i386, CPU features:)
Building for:  devices/linux-a20olimex-g++ (arm, CPU features: neon)
Platform notes:

            - Also available for Linux: linux-kcc linux-icc linux-cxx
       
qmake vars .......... styles += mac fusion windows DEFINES += QT_NO_MTDEV QT_CFLAGS_DBUS = -I/mnt/a20//usr/include/dbus-1.0 -I/mnt/a20//usr/lib/arm-linux-gnueabihf/dbus-1.0/include   QT_LIBS_DBUS = -L/mnt/a20//usr/lib/arm-linux-gnueabihf -ldbus-1   QT_CFLAGS_GLIB = -pthread -I/mnt/a20//usr/include/glib-2.0 -I/mnt/a20//usr/lib/arm-linux-gnueabihf/glib-2.0/include   QT_LIBS_GLIB = -pthread -L/mnt/a20//usr/lib/arm-linux-gnueabihf -lgthread-2.0 -lrt -lglib-2.0   QT_CFLAGS_PULSEAUDIO = -D_REENTRANT -I/mnt/a20//usr/include/glib-2.0 -I/mnt/a20//usr/lib/arm-linux-gnueabihf/glib-2.0/include   QT_LIBS_PULSEAUDIO = -L/mnt/a20//usr/lib/arm-linux-gnueabihf -lpulse-mainloop-glib -lpulse -lglib-2.0   QMAKE_CFLAGS_FONTCONFIG = -I/mnt/a20//usr/include/freetype2   QMAKE_LIBS_FONTCONFIG = -L/mnt/a20//usr/lib/arm-linux-gnueabihf -lfontconfig -lfreetype   QMAKE_INCDIR_LIBUDEV =   QMAKE_LIBS_LIBUDEV = -ludev   DEFINES += QT_NO_XCB DEFINES += QT_NO_XKBCOMMON sql-drivers =  sql-plugins =  sqlite qmake switches .........

Build options:
  Configuration .......... accessibility alsa audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cross_compile dbus egl eglfs evdev eventfd fontconfig full-config getaddrinfo getifaddrs glib iconv icu inotify ipv6ifname large-config largefile libudev linuxfb medium-config minimal-config mremap neon nis no-harfbuzz opengl opengles2 openssl pcre png posix_fallocate pulseaudio qpa qpa reduce_exports reduce_relocations release rpath shared small-config system-freetype system-png system-zlib xlib
  Build parts ............  libs
  Mode ................... release
  Using C++11 ............ yes
  Using PCH .............. no
  Target compiler supports:
    iWMMXt/Neon .......... no/yes

Qt modules and options:
  Qt D-Bus ............... yes (loading dbus-1 at runtime)
  Qt Concurrent .......... yes
  Qt GUI ................. yes
  Qt Widgets ............. yes
  JavaScriptCore JIT ..... yes (To be decided by JavaScriptCore)
  QML debugging .......... yes
  Use system proxies ..... no

Support enabled for:
  Accessibility .......... yes
  ALSA ................... yes
  CUPS ................... no
  FontConfig ............. yes
  FreeType ............... system
  Iconv .................. yes
  ICU .................... yes
  Image formats:
    GIF .................. yes (plugin, using bundled copy)
    JPEG ................. yes (plugin, using bundled copy)
    PNG .................. yes (in QtGui, using system library)
  Glib ................... yes
  GTK theme .............. no
  Large File ............. yes
  mtdev .................. no
  Networking:
    getaddrinfo .......... yes
    getifaddrs ........... yes
    IPv6 ifname .......... yes
    OpenSSL .............. yes (loading libraries at run-time)
  NIS .................... yes
  OpenGL ................. yes (OpenGL ES 2.x)
  OpenVG ................. no
  PCRE ................... yes (bundled copy)
  pkg-config ............. yes
  PulseAudio ............. yes
  QPA backends:
    DirectFB ............. no
    EGLFS ................ yes
    KMS .................. no
    LinuxFB .............. yes
    XCB .................. no
  Session management ..... yes
  SQL drivers:
    DB2 .................. no
    InterBase ............ no
    MySQL ................ no
    OCI .................. no
    ODBC ................. no
    PostgreSQL ........... no
    SQLite 2 ............. no
    SQLite ............... yes (plugin, using bundled copy)
    TDS .................. no
  udev ................... yes
  xkbcommon .............. no
  zlib ................... yes (system library)

NOTE: Qt is using double for qreal on this system. This is binary incompatible against Qt 5.1.
Configure with '-qreal float' to create a build that is binary compatible with 5.1.
Info: creating super cache file /home/sti/Downloads/qt-everywhere-opensource-src-5.2.1/.qmake.super

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/a20files

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.



And this is the make output:


                       ^
../../../../include/QtCore/../../src/corelib/io/qurl.h:348:24: warning: 'QStringList idnWhitelist()' declared 'static' but never defined [-Wunused-function]
     static QStringList idnWhitelist();
                        ^
../../../../include/QtCore/../../src/corelib/io/qurl.h:349:24: warning: 'QStringList toStringList(const QList<QUrl>&, FormattingOptions)' declared 'static' but never defined [-Wunused-function]
     static QStringList toStringList(const QList<QUrl> &uris, FormattingOptions options = FormattingOptions(PrettyDecoded));
                        ^
../../../../include/QtCore/../../src/corelib/io/qurl.h:350:24: warning: 'QList<QUrl> fromStringList(const QStringList&, int)' declared 'static' but never defined [-Wunused-function]
     static QList<QUrl> fromStringList(const QStringList &uris, ParsingMode mode = TolerantMode);
                        ^
../../../../include/QtCore/../../src/corelib/io/qurl.h:352:17: warning: 'void setIdnWhitelist(const QStringList&)' declared 'static' but never defined [-Wunused-function]
     static void setIdnWhitelist(const QStringList &);
                 ^
make[5]: *** [.obj/qeglfsintegration.o] Error 1
make[5]: Leaving directory `/home/sti/Downloads/qt-everywhere-opensource-src-5.2.1/qtbase/src/plugins/platforms/eglfs'
make[4]: *** [sub-eglfs-make_first] Error 2
make[4]: Leaving directory `/home/sti/Downloads/qt-everywhere-opensource-src-5.2.1/qtbase/src/plugins/platforms'
make[3]: *** [sub-platforms-make_first] Error 2
make[3]: Leaving directory `/home/sti/Downloads/qt-everywhere-opensource-src-5.2.1/qtbase/src/plugins'
make[2]: *** [sub-plugins-make_first] Error 2
make[2]: Leaving directory `/home/sti/Downloads/qt-everywhere-opensource-src-5.2.1/qtbase/src'
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory `/home/sti/Downloads/qt-everywhere-opensource-src-5.2.1/qtbase'
make: *** [module-qtbase-make_first] Error 2

Cosik

In your output only warnings are visible. Please execute only 'make' not 'make -j 5'.

If you are using A20 for compile you should not use -j 5 because A20 have only 2 cores.