Cross compile Qt (Windows) to Raspberry 3



  • Hi,
    I've been looking for informations on how to configure the cross compilation on qt (windows) for the raspberry 3. I don't know if it's the place to write it, but for people who are interested in, here is how I did the cross compilation beetwee windows 8 and raspberry pi 3 (debian jessie).

    Most of steps come from the tuto here : http://visualgdb.com/tutorials/raspberry/qt/embedded/
    Based on that, here are the changes I made to make it work for the rpi3 :

    1. Open this : http://visualgdb.com/tutorials/raspberry/qt/embedded/

    2. Follow STEP 2.

    3. WARNING : For step 3, you need to change MinGW32 with MinGW64 with gcc >= 4.9. So download it, and install it in C:/SysGCC/MinGW64

    4. Follow step 4.

    5. For step 5., download qt-everywhere >= 5.6 (otherwise rpi3 won't be supported)

    6. Follow step 6.

    7. From here, all the cmd line on the terminal must be done on msys2 MinGW64 !
      Download MSYS2, install it in C:/SysGCC/MinGW64/msys2
      Open mingw64_shell
      Run those cmd to update the needed libs :

      	pacman -S make
      	pacman -S perl
      	pacman -S pkg-config
      	pacman -S diffutils
      

      Continue the tuto with this shell

    8. Follow step 8.

    9. Step 9 : check that gcc is linked to MinGW64/bin/gcc.exe

    10. Follow 10. and 11.

    11. For step 12, change "linux-rasp-pi2-g++" to "linux-rpi3-g++"
      PS : you can add the "-nomake examples" in the configure cmd lines if you don't need them to save time
      PS2 : opengl and libxcb may have some link troubles, I removed them, I use linuxfb

    12. Follow 13-14-15

    13. Follow step 16
      Ex : In my case, the cmd was :

      ../qt-everywhere-opensource-src-5.6.1/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -device linux-rpi3-g++ -sysroot C:/SysGCC_RPi3/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5 -device-option CROSS_COMPILE=C:/SysGCC_RPi3/Raspberry/bin/arm-linux-gnueabihf- -nomake examples -opensource -confirm-license
      
    14. Now, if you're configuration file has been well generated, launch "make && make install" (step 17.)

    15. Copy the built qt from C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot/usr/local/qt5 to your pi3 in /usr/local/qt5 (step 18 - end)

    There should be different ways to make it work, maybe this is not the best one, but it works for me. Hope it's helpful, sorry if i'ts not the place.

    Etienne



  • All fine until step 13.

    Excuting the following command:

    ../qt-everywhere-opensource-src-5.6.1/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -device linux-rpi3-g++ -sysroot F:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5 -device-option CROSS_COMPILE=F:/SysGCC/Raspberry/bin/arm-linux-gnueabihf- -nomake examples -opensource -confirm-license -qt-xcb -v

    generates a lot of error messages like:
    ... arm-linux-gnueabihf-g++.exe: error: unrecognized command line option '-std=c++1z' ...

    Any advise?

    ======================================================
    Update:

    1. I finally gave up on cross compile
    2. installed QT/Creator on pi3 (actually the build time for what I'm doing is not too bad)
    3. vnc access from PC is ok


  • Hi,

    I'm trying to install QT5.7 environment with Raspberry PI3 support. I'm using MINGW64 and QT-everywhere 5.7.0. For some reason 5.7.0 requires c++11, which my env doesn't have. Step 16 will fail for that. QT 5.6.1 is fine with c++, but is having problems OpenGL ES 2.0.

    Would be great if some guru would update instructions for RPI3.

    Thanks in advance.

    Br,
    Hannu

    ==============================

    edit:

    1. When merged linux-arm-gnueabi-g++\qmake.conf from QT-everywhere 5.7.0 to 5.6.1 OpenGL problem was solved.
    2. "pacman -S python" was also needed for make


  • @etiennedm
    Silly question but what advantages are in this solution special for RPi3 when tutorial by sysprogs itself is useable on RPi3?



  • @pVit Can you tell us how you got the tutorial by sysprogs to work? I think most people are having problems getting it to work.



  • @Garyio
    What problem do you have? I did everything in tutorial, used mingw32-gcc 4.7.2, python 2.7.11 and raspberry-gcc 4.6.3 and everything is okay.



  • @Hannu Hi, you said Qt5.6.1 has problems with opengl es? What is the problem ?



  • Where to download MINGW64 gcc 4.9.2


  • Moderators

    @lygstate The easiest way is to use Qt Maintenance Tool if you used Qt Online Installer to install Qt.
    Also, how is your question related to this thread?



  • How to exclude qtscript from build?



  • If the steps is not appear, then following the steps in https://visualgdb.com/tutorials/raspberry/qt/embedded/, otherwise using the steps below instead

    • Steop 8: Edit ~/.bashrc
      Append following lines

      export PATH=$PATH:/c/SysGCC/mingw32/bin
      export PATH=$PATH:/c/Python27
      export PATH=$PATH:/c/SysGCC/Raspberry/bin
      mkdir -p /c/SysGCC/qt-build
      cd /c/SysGCC/qt-build
      

      open msys2/mingw32.exe

    • Step 9: Check that gcc is linked to C:/SysGCC/mingw32/bin/gcc.exe

    • Step10: Prepare the source code
      Copy folder qt-everywhere-opensource-src-5.8.0\qtbase\mkspecs\linux-arm-gnueabi-g++\
      and it's contents as
      qt-everywhere-opensource-src-5.8.0\qtbase\mkspecs\linux-arm-gnueabihf-g++\
      in folder qt-everywhere-opensource-src-5.8.0\qtbase\mkspecs\linux-arm-gnueabihf-g++\
      grep -irn arm-linux-gnueabi- arm-linux-gnueabihf- .

      Edit qt-everywhere-opensource-src-5.8.0\qtbase\mkspecs\devices\linux-rpi3-g++\qmake.conf
      Replace part lines with (This should also works for Qt 5.6.1, not tested for OpenGL ES):

      VC_LIBRARY_PATH         = $$[QT_SYSROOT]/opt/vc/lib
      VC_INCLUDE_PATH         = $$[QT_SYSROOT]/opt/vc/include
      
      QMAKE_LFLAGS           += -L$${VC_LIBRARY_PATH}
      
      VC_LINK_LINE            = -L$${VC_LIBRARY_PATH}
      
    • Step 12: Configure for Host & Target(Only Qt 5.8 and upper, Qt 5.7 not tested)
      For Qt 5.8 Host & Target
      No step 16, results are in step 16.

      ../qt-everywhere-opensource-src-5.8.0/configure -skip qtscript -platform win32-g++ -xplatform linux-arm-gnueabihf-g++ -release -device linux-rpi3-g++ -sysroot C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5 -device-option CROSS_COMPILE=C:/SysGCC/Raspberry/bin/arm-linux-gnueabihf- -nomake examples -opensource -confirm-license
      

      For Qt 5.6 and lower, Only Host

      ../qt-everywhere-opensource-src-5.6.1/configure -skip qtscript -platform win32-g++ -xplatform linux-arm-gnueabihf-g++ -release -device linux-rpi3-g++ -sysroot C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5 -opensource -confirm-license
      
    • Step13: Skip

    • Step 14: This is normal as long as qmake.exe got built. Check this by running qtbase/bin/qmake -v

    • Step 15: Skip

    • Step 16: Configure the Target (Only Qt 5.6 and lower), otherwise Skip it
      Remove -std=c++1z from qt-everywhere-opensource-src-5.6.1\qtbase\mkspecs\devices\linux-rpi3-g++\qmake.conf
      Qt 5.6.x execute the following command

      ../qt-everywhere-opensource-src-5.6.1/configure -skip qtscript -platform win32-g++ -xplatform linux-arm-gnueabihf-g++ -release -device linux-rpi3-g++ -sysroot C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5 -device-option CROSS_COMPILE=C:/SysGCC/Raspberry/bin/arm-linux-gnueabihf- -nomake examples -opensource -confirm-license
      
    • Step 17: Building And Install

      make && make install
      

  • Moderators

    @lygstate Pass this to configure:

    -skip qtscript
    


  • @jsulm Thanks, I am using this method.



  • I do all the tuto and i can make a excutable with qt but the qlabel and the qpushbutton it isn't show. i think it's because when create the qmake the modul gtk isn't enable. when i try to enable it that said

    ERROR: Feature 'gtk3' was enabled, but the pre-condition 'features.glib && libs.gtk3' failed.

    it's do 1 week i try to fine how to fix the pre-condition.


  • Moderators

    @CrazyCreepy "qlabel and the qpushbutton it isn't show" - what does it mean? Are they not shown at all, or no text?
    For gtk3 support you probably need to install gtk3 dev packages, but it actually should work without.
    If there is no text then you probably have some font issues.



  • @jsulm I mean the label and push button doesn't exist! if i wants to close my windows i will use httop... it work without gtk3 but not all feature is enable and this can be very problematic later... and i installe Gtk3 on my rasp, but they change noting i need to configure in my compiler but i don't know how .


  • Moderators

    @CrazyCreepy As I said you need to install gtk3/glib dev packages on your RPi/sysroot and then build Qt (there is nothing to configure in compiler).
    "label and push button doesn't exist" - you probably mean - they are not shown?



  • that what i get on my raspberry pi
    alt text
    and that was i get
    alt text

    I have already install the glib and gtk3 on my raspberry... I also try to syncronize all of my raspberry pi with smartputty in my sysroot and it's doesn't work... I'm little exhausted of this.... thanks for help.



  • Hello.

    Very good instructions to config QT5 for RPY3 with cross. I try to install but fail in step6, seem some permissions problem, but do not know why, I work with Administrator user, and I have change permissions to all files to get access to all users.

    This is capture screen about fail when I try to run step 6 to syncronize sysroot. Somebody may help me, why fail ??. Translation to english language about the error message is "Cannot connect: Try to access to one socket not allowed because your access permissions 192.168.1.7"

    If I run directly StmarTTY from Windows work perfectly, but I run SmarTTY from a DOS window also fail with same error message,

    alt text



  • .

    Hello.

    My before problem was because the firewall, already solved. I have follow instructions of lystate user, and all seem ok but fail in last step, with this error message.

    Somebody know how to solve this problem to may compile ??

    alt text

    .

    And this is the content of the config.log file:

    executing config test use_gold_linker
    cd C:\SysGCC\qt-build\qtbase\config.tests && C:/SysGCC/Raspberry/bin/arm-linux-gnueabihf-g++ -fuse-ld=gold -o conftest-out conftest.cpp
    cc1plus.exe: error: unrecognized command line option '-fuse-ld=gold'

    test config.qtbase.tests.use_gold_linker FAILED
    executing config test verifyspec

    cd C:\SysGCC\qt-build\qtbase\config.tests\common\verifyspec && C:\SysGCC\qt-build\qtbase\bin\qmake.exe -qtconf C:/SysGCC/qt-build/qtbase/bin/qt.conf "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared console" "QMAKE_CFLAGS += --sysroot=C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot" "QMAKE_CXXFLAGS += --sysroot=C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot" "QMAKE_LFLAGS += --sysroot=C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot" C:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/config.tests/common/verifyspec

    cd C:\SysGCC\qt-build\qtbase\config.tests\common\verifyspec && set MAKEFLAGS=& C:/SysGCC/msys2/usr/bin/make

    C:/SysGCC/Raspberry/bin/arm-linux-gnueabihf-g++ -c -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard --sysroot=C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -O2 -Wall -W -fPIC -IC:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/config.tests/common/verifyspec -I. -IC:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/mkspecs/devices/linux-rpi3-g++ -o verifyspec.obj C:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/config.tests/common/verifyspec/verifyspec.cpp

    cc1plus.exe: error: bad value (armv8-a) for -march switch
    cc1plus.exe: error: bad value (cortex-a53) for -mtune switch

    C:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/config.tests/common/verifyspec/verifyspec.cpp:1:0: error: invalid floating point option: -mfpu=crypto-neon-fp-armv8
    make: *** [Makefile:176: verifyspec.obj] Error 1
    executing config test verifyspec

    cd C:\SysGCC\qt-build\qtbase\config.tests\common\verifyspec && C:\SysGCC\qt-build\qtbase\bin\qmake.exe -qtconf C:/SysGCC/qt-build/qtbase/bin/qt.conf "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared console" "QMAKE_CFLAGS += --sysroot=C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot" "QMAKE_CXXFLAGS += --sysroot=C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot" "QMAKE_LFLAGS += --sysroot=C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot" C:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/config.tests/common/verifyspec

    cd C:\SysGCC\qt-build\qtbase\config.tests\common\verifyspec && set MAKEFLAGS=&

    C:/SysGCC/msys2/usr/bin/make clean && set MAKEFLAGS=& C:/SysGCC/msys2/usr/bin/make
    rm -f verifyspec.obj
    rm -f *~ core *.core

    C:/SysGCC/Raspberry/bin/arm-linux-gnueabihf-g++ -c -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard --sysroot=C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -O2 -Wall -W -fPIC -IC:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/config.tests/common/verifyspec -I. -IC:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/mkspecs/devices/linux-rpi3-g++ -o verifyspec.obj C:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/config.tests/common/verifyspec/verifyspec.cpp

    cc1plus.exe: error: bad value (armv8-a) for -march switch
    cc1plus.exe: error: bad value (cortex-a53) for -mtune switch

    C:/SysGCC/qt-everywhere-opensource-src-5.8.0/qtbase/config.tests/common/verifyspec/verifyspec.cpp:1:0: error: invalid floating point option: -mfpu=crypto-neon-fp-armv8

    make: *** [Makefile:176: verifyspec.obj] Error 1


  • Moderators

    @pinballsp armv8-a? Shouldn't it be armv7 for RPi? Please show your configure call.



  • @lygstate I followed your steps in details, but it looks like there is something wrong in step 10. My compilation terminates due to #include <EGL/egl.h> not found.

    Please can you elaborate step 10 again. Inside the directory "qt-everywhere-opensource-src-5.8.0\qtbase\mkspecs" , there only exist "linux-arm-gnueabi-g++" and no other directory called "linux-arm-gnueabihf-g++" under that path found.
    Is it the same to open "qt-everywhere-opensource-src-5.8.0\qtbase\mkspecs\linux-arm-gnueabi-g++\qmake.conf" and change every instance of arm-linux-gnueabi- with arm-linux-gnueabihf- ??

    Any way the error I get is as follows:

    ![alt text](0_1489304405176_upload-81c91e98-131a-4bbd-8fd1-dc35406c5dd6 image url)

    Please did you go through all these steps and compiled 5.8 at the end ?

    Thanks in advance



  • Hi etiennedm,
    thanks for your detailed description.
    But I'm sorry I get stuck at step 7, because I can't find a directory named
    C:/SysGCC/MinGW64/msys2.
    What's wrong there?
    Thanks a lot for your answer in advance.
    Regards Kurt


Log in to reply
 

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