Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Illegal instruction" when trying to run cross-compiled Qt on Raspberry Pi (Windows)

I have found and read the question here, also threads here and here, unfortunately it still remains unresolved. (though I used all the tips from that thread to give as much info as I can)


What's the problem

For a few days I've been trying to find a way to bo able to cross-compile Qt , as I got one recently and now wanted to learn how to code some basic embedded apps.

I'm following the tutorial here: http://visualgdb.com/tutorials/raspberry/qt/embedded/

  • I used a clean system, the only thing I had to install were some depedencies: apt-get install libudev-dev libinput-dev libts-dev libxcb*(running it for the first time, configure was saying about missing libs)
  • Got Raspbian image and toolchain from here, respectively 2015-11-21-raspbian-jessie and raspberry-gcc-4.9.2-r2.exe
  • Qt source also comes from the link in the tutorial above (qt-everywhere-opensource-src-5.5.0.tar.xz)
  • I used the same file paths etc, so all the commands should be fine, including the configure: ../qt-everywhere-opensource-src-5.5.0/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -opengl es2 -device linux-rasp-pi2-g++ -sysroot C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5 -device-option CROSS_COMPILE=C:/SysGCC/Raspberry/bin/arm-linux-gnueabihf- -qt-xcb

After several hours everything were built, presumably without errors. (my output was more less the same as on the screenshots in the tutorial)

However, trying to run any of the examples built, results in just one line: Illegal instruction


What more can I provide...

  • Following the thread I mentioned at the beginning, here's the file output:

    root@raspberrypi:/usr/local/qt5/examples/opengl/cube# file cube
    
    cube: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically
    linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32,
    BuildID[sha1]=e4c51318d4ca583ace647510c9b4cddd06a34e19, stripped
    
  • I tried to run the app with gdb using gdb ./cube and then run. The output is:

    (gdb) run
    Starting program: /usr/local/qt5/examples/opengl/cube/cube 
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
    
    Program received signal SIGILL, Illegal instruction.
    0xb6249734 in QMutex::lock() () from /usr/local/qt5/lib/libQt5Core.so.5
    (gdb) Quit
    
  • The compiler itself work as cross-compile - I'm able to build C++ Hello World on windows, compile using C:\SysGCC\Raspberry\bin\arm-linux-gnueabihf-g++.exe and then run it on Raspberry

  • I was even able to configure Qt Creator properly, using arm-linux-gnueabihf-g++.exe as a compiler and C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\qt5\bin\qmake.exe as qmake - Basic opengl project builds fine, even remote deploying to raspi works :) ... pity about the "Illegal instruction"

  • Raspbian: Linux raspberrypi 4.1.19+ #858 Tue Mar 15 15:52:03 GMT 2016 armv6l GNU/Linux

    root@raspberrypi:/# lsb_release -a
    No LSB modules are available.
    Distributor ID: Raspbian
    Description: Raspbian GNU/Linux 8.0 (jessie)
    Release: 8.0
    Codename: jessie
    
  • Windows 7 64 bit


Thanks in advance for any help. Of course I would give any necessary info if needed.

Seriously, I'm trying for a week, already failed with linux-like stuff on wiki.qt.io wiki.qt.io Still, I'm really looking forward to make a robust, cross-compile, remote-deploy Qt environment for future developing on my Raspberry from Windows :)

like image 762
Skipper Avatar asked Mar 29 '16 19:03

Skipper


1 Answers

Well it turned out to be embarrassingly obvious. The tutorial here: http://visualgdb.com/tutorials/raspberry/qt/embedded/ is made for Raspberry Pi 2, although it's not mentioned explicitly

Luckily you just need to change configure script from -device linux-rasp-pi2-g++ to -device linux-rasp-pi-g++

I was surprised, but apparently it worked perfectly for me.

So now the configure line should look like this:

../qt-everywhere-opensource-src-5.5.0/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -opengl es2 -device linux-rasp-pi-g++ -sysroot C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5 -device-option CROSS_COMPILE=C:/SysGCC/Raspberry/bin/arm-linux-gnueabihf- -qt-xcb

Thanks @Bugfinger for a hint :)

PS. If you don't know which version of RPi you have (I wasn't sure at all), you can compare specs and peripherals here or here

like image 179
Skipper Avatar answered Oct 03 '22 00:10

Skipper