Cross Compile Qt app wont open



  • Hello, I am trying to cross compile Qt GUI programs to the Pi and all goes well until I try to execute the program. It gives me this error.

    Unable to query physical screen size, defaulting to 100 dpi.
    To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).

    The program compiles fine, then is transferred to the Pi directory. If I try to run it through commandline, it will give me the correct console output, (eg, saying its IP and saying hello) so I know everything else seems to be fine besides the GUI window. Does anyone know what is wrong?



  • Strange...So when I am using my little PiTFT screen I get that error and nothing is shown. However, when I plug in my HDMI cable, the GUI is shown on the monitor.

    Why would compiling natively work with the small screen and cross compiling only allow HDMI?



  • I was able to get around the HDMI error.

    I am getting weird unexpected results from my application.

    This is a simple dial, like a RPM meter with a needle that rotates. If I native compile the program on the Pi, the dial looks completely fine and the needle turns as it should. the GUI is shown as a window on top of the desktop.

    Now if I cross compile over to the Pi, the GUI takes up the whole screen and the needle rotates around a different point, not the centre of the dial image. Additionally, the GUI seems to be "overlayed" on top of the desktop so that if I click on the GUI, it clicks on the desktop beneath the GUI too.

    it must have something to do with the original error message of "Unable to query physical screen size, defaulting to 100 dpi." Which it doesnt complain about when natively compiled.
    I dont know why there is that difference.



  • I am getting closer to solving the problem.

    The application is automatically opening in eglfs which makes it open in full screen and
    I stumbled across this post https://www.raspberrypi.org/forums/viewtopic.php?t=42587&p=350001

    My platform options were eglfs, linuxfb, minimal, minimalegl, and offscreen. linuxfb resulted in a better looking GUI but wasnt perfect.

    That thread wasnt resolved, and I am wondering what I should do now? Is there an issue with X11 and Qt5? What are they talking about xcb?



  • I'm also interested in hearing about a solution to this. I've just finished compiling QT 5.5 on my raspberry pi 2 and when I run a simple app, it goes to full screen. I can't do anything with it, so I have to plug my pc in and kill the process. I don't have a touch screen for my pi yet, so I was hoping to develop using a screen attached to HDMI.
    I followed this article Native Build of QT 5.4.1 on Raspberry PI but obviously I misunderstood that it was for a pi with a touch screen.

    Do I have to recompile or is there something else I can do to get my app to open in a window?



  • Ok, so here is what I did.
    First, take your Pi and install xcb
    sudo apt-get install libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev

    You will also need mesa-common-dev to solve an OpenGL error.
    sudo apt-get install mesa-common-dev

    Next, take out your Pi SD card. Save the image on your PC, and mount the raspbian image. Re-cross-compile qt5 with the -qt-xcb tag in the configure step. Change ~/opt/mnt/rasp-pi-rootfs if thats not where your rootfs is.

    ./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf- -sysroot ~/opt/mnt/rasp-pi-rootfs -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5pi -hostprefix /usr/local/qt5pi -qt-xcb -v > outputConfigure.txt

    Once that is done, make everything.
    make -j 12
    sudo make install

    cd qtimageformats
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtsvg
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtjsbackend
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtscript
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtxmlpatterns
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtdeclarative
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtsensors
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qt3d
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtgraphicaleffects
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtjsondb
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtlocation
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtdocgallery
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    cd qtwebsockets
    /usr/local/qt5pi/bin/qmake
    make -j 12
    sudo make install

    Unmount the image and save it back onto the SD card. You now have xcb!

    Log back into the pi and set environment variable. This will tell Qt apps to always open in xcb
    sudo nano ~/.profile

    place the following inside and save:
    export QT_QPA_PLATFORM=xcb

    Works like a charm!



  • @Hyprodimus-Prime said:

    You will also need mesa-common-dev to solve an OpenGL error.

    Hello, I'd like to know more about this comment. What was the error?

    Thanks in advance.



  • @Hyprodimus-Prime i have completed the cross compilation but while making some of my folders like qtjsbackend, qtdocgallery were empty so what may be the possible reason for that and how it is going to effect my functioning


Log in to reply
 

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