How Far We’ve Come – Pt. 18

The Internet has no shortage of “how to cross compile Qt for Pi Web pages.” Most of them kind of were “right enough” at one point in time for a subset of people. Most of them don’t bother to tell you what the host system is. I suspect many of them used a 32-bit host system which masked most of the problems with their instructions. The instructions found here definitely fall into this category. How do I know that? I followed them for a bit because I liked not having to loop mount an image. Really weird things can happen when images for a different CPU are loop mounted and something goes wrong. Another reason I followed them is that they appeared to be an update for the official Qt Wiki article using the same method.

Yes, everyone wants to believe the instructions they found are a fine Cuban cigar. On the Internet, even when they are “just posted today” they tend to be closer to a Lucky Strike someone ripped the filter off of then left lay on a shelf for 7+ years.

When I got to the configure step I tried to use this:


./configure -release -opengl es2 \
-opensource -confirm-license -plugin-sql-psql -qt-sql-sqlite \
-device linux-rasp-pi2-g++ \
-device-option CROSS_COMPILE=~/piBuild/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- \
-sysroot ~/piBuild/sysroot -prefix /usr/local/qt5pi \
-extprefix ~/piBuild/qt5pi \
-hostprefix ~/piBuild/qt5 -v

I wanted to be sure we compiled support for the PostgreSQL plugin and that we used the SQLite which came with Qt. The first signs of problems came early on:

psql.cpp:40:22: fatal error: libpq-fe.h: No such file or directory
 #include "libpq-fe.h"
compilation terminated.
Makefile:198: recipe for target 'psql.o' failed
make: *** [psql.o] Error 1
PostgreSQL disabled.
PostgreSQL support cannot be enabled due to functionality tests!
 Turn on verbose messaging (-v) to /home/roland/piBuild/qt-everywhere-opensource-src-5.7.1/qtbase/configure to see th

Given I had quite a few distractions, I did some searching to see which Debian package provided that header and installed it. Yes, it’s okay. You can say it out loud. I’m stupid some times. I should have known right then and there this build procedure wasn’t worthless shit. I should have also went to the bottom of that post and looked at all of the comments from people trying to build on a 64-bit host asking if this procedure was ever tested.

sudo apt install libpq-dev

Stubborn can be good, but stubborn and stupid tends not to be a winning combination.

Adding insult to injury, this very site where I wish to write posts about this started having severe intestinal disorders so I was fighting that while working on this and getting on with my life.

I warned you at the start of this series, you aren’t getting one of my clean and polished books where I worked through everything the first time, then re-tested on a clean system so I knew everything I put in there worked. You are getting a merger of hundreds of note files taken while I was figuring it out. The bad part here is I’ve been away from this for a couple of weeks so you really are getting a compilation of note files I could find rather than a direct flow of conscious.

This build attempt proves what a horrible debacle these instructions are. I installed that package on both the Pi and my 64-bit compilation machine. I redid all of the rsync stuff and reran the fixup script before launching another attempt at getting PostgreSQL to work.

checking for PostgreSQL... 
/home/roland/piBuild/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -c -pipe -march=armv7-a -marm -mthumb-interwork -mfpu=neon-vfpv4 -mtune=cortex-a7 -mabi=aapcs-linux -mfloat-abi=hard --sysroot=/home/roland/piBuild/sysroot -O2 -Wall -W -fPIC -I. -I/usr/include/postgresql -I../../../mkspecs/devices/linux-rasp-pi2-g++ -o psql.o psql.cpp
/home/roland/piBuild/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link,/home/roland/piBuild/sysroot/opt/vc/lib -Wl,-rpath-link,/home/roland/piBuild/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/roland/piBuild/sysroot/lib/arm-linux-gnueabihf -mfloat-abi=hard -Wl,-O1 -o psql psql.o --sysroot=/home/roland/piBuild/sysroot -L/usr/lib/x86_64-linux-gnu -lpq 
/usr/lib/x86_64-linux-gnu/ file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
Makefile:92: recipe for target 'psql' failed
make: *** [psql] Error 1
PostgreSQL disabled.
PostgreSQL support cannot be enabled due to functionality tests!
 Turn on verbose messaging (-v) to /home/roland/piBuild/qt-everywhere-opensource-src-5.7.1/qtbase/configure to see the final report.
 If you believe this message is in error you may use the continue
 switch (-continue) to /home/roland/piBuild/qt-everywhere-opensource-src-5.7.1/qtbase/configure to continue.
roland@roland-desktop:~/piBuild/qt-everywhere-opensource-src-5.7.1$ cd /
roland@roland-desktop:/$ sudo find -iname
[sudo] password for roland: 

You will note the library from the Pi is exactly where it should be. Either the instructions for configuring the environment are incorrect on the blog/wiki, or the cross compile configure scripts are incorrect.

Leaving PostgreSQL out of it, the build still crashes.

/home/roland/piBuild/qt-everywhere-opensource-src-5.7.1/qtbase/include/QtCore/../../src/corelib/tools/qhash.h:235:45: warning: cast from ‘QHashData::Node*’ to ‘QHash<QString, QVariant>::Node* {aka QHashNode<QString, QVariant>*}’ increases required alignment of target type [-Wcast-align]
 return reinterpret_cast<Node *>(node);
make[4]: *** [invoke_ninja] Error 1
make[3]: *** [sub-gyp_run-pro-make_first] Error 2
make[2]: *** [sub-core-make_first] Error 2
make[1]: *** [sub-src-make_first] Error 2
make: *** [module-qtwebengine-make_first] Error 2
make: *** Waiting for unfinished jobs....

As I said, neither wiki page nor the blog stated what their build machine was. They also didn’t state what was installed. There was one telling line in this post though.

Make sure your Qt Creator installation works for native development using a native Qt version running on your desktop, as this is a prerequisite to extending it to work for embedded development.

While it is all well and good to have some development machine which built and ran a desktop version of your application, it is a rather horrible idea to put together cross compile instructions based on that same machine. This would never fly in an FDA regulated environment where you have to be able to create from scorched earth your cross compile environment.

I finally used this configure command.

./configure -release -opengl es2 -opensource -confirm-license -qt-sql-sqlite -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=~/piBuild/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- -sysroot ~/piBuild/sysroot -prefix /usr/local/qt5pi -extprefix ~/piBuild/qt5pi -hostprefix ~/piBuild/qt5 -v -skip webengine

While this does cleanly build, our PostgreSQL test application does not.



Related Posts:

QT Database book

AGILE book

Where Did My QDebug Output Go?

MOC Parse Error at “std”

KDE Neon – Distcc and Qt

CopperSpice Experiments

QtCreator – No qmlScene installed

So You Can’t Get Your Models to Work with QML?