Solved cross-compiling on Ubuntu to rpi B+ raspbian stretch
-
@flemingp Add -v to configure command and check the output - you should see what exactly is missing.
-
Thank you for your reply, I am already using -v, and had posted the output above. I believe the problem relates specifically to:
bluetooth/bluetooth.h: No such file or directory > #include <bluetooth/bluetooth.h>
I don't understand why it is not found when the file does exist in the sysroot, and as part of trying to resolve the error I have tried both an additional Include of -I~/raspi/sysroot/usr/include/ and also -I~/raspi/sysroot/usr/include/bluetooth.
-
@flemingp So, ~/raspi/sysroot/usr/include/bluetooth/bluetooth.h exists?
-
Indeed it does along with the header file
paul@paul-X200CA:~/raspi/sysroot/usr/include/bluetooth$ ls bluetooth.h bnep.h cmtp.h hci.h hci_lib.h hidp.h l2cap.h rfcomm.h sco.h sdp.h sdp_lib.h paul@paul-X200CA:~/raspi/sysroot/usr/include/bluetooth$
And sysroot is passed in configure command, noting that the sql module builds and compiles with not problems:
../qt-everywhere-src-5.11.2/configure -opengl es2 -device rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -I~/raspi/sysroot/usr/include/ -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v -no-use-gold-linker -nomake examples -no-compile-examples -nomake tests -skip qtwayland -skip qtwebengine -sql-mysql MYSQL_INCDIR=~/raspi/sysroot/usr/include/mysql MYSQL_LIBDIR=~/raspi/sysroot/usr/lib/arm-linux-gnueabihf --recheck-all ``
-
@flemingp said in cross-compiling on Ubuntu to rpi B+ raspbian stretch:
~/
Use full path, not
~
sign. It sometimes gets in the way. -
Used full path for sysroot with configure, same problem:
../qt-everywhere-src-5.11.2/configure -opengl es2 -device rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /home/paul/raspi/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v -no-use-gold-linker -nomake examples -no-compile-examples -nomake tests -skip qtwayland -skip qtwebengine -sql-mysql MYSQL_INCDIR=~/raspi/sysroot/usr/include/mysql MYSQL_LIBDIR=~/raspi/sysroot/usr/lib/arm-linux-gnueabihf --recheck-all
-
By adding -I/home/paul/raspi/sysroot/usr/include/ -L/home/paul/raspi/sysroot/usr/lib/arm-linux-gnueabihf I have overcome the build error and am currently compiling. I have not marked this as solved, because I believe sysroot should pass the path without having to add it manually. But I am a novice so happy to stand corrected.
-
@flemingp said in cross-compiling on Ubuntu to rpi B+ raspbian stretch:
I believe sysroot should pass the path without having to add it manually.
You're right, usually it is not necessary.
-
I spoke too soon, with the full paths I now get the following error when I run make:
/home/paul/raspi/qt-everywhere-src-5.11.2/qtbase/src/corelib/io/qfilesystemengine_unix.cpp: In static member function ‘static bool QFileSystemEngine::renameFile(const QFileSystemEntry&, const QFileSystemEntry&, QSystemError&)’: /home/paul/raspi/qt-everywhere-src-5.11.2/qtbase/src/corelib/io/qfilesystemengine_unix.cpp:1286:19: error: ‘AT_FDCWD’ was not declared in this scope if (renameat2(AT_FDCWD, srcPath, AT_FDCWD, tgtPath, RENAME_NOREPLACE) == 0) ^~~~~~~~ /home/paul/raspi/qt-everywhere-src-5.11.2/qtbase/src/corelib/io/qfilesystemengine_unix.cpp:1286:19: note: suggested alternative: ‘QT_GETCWD’ if (renameat2(AT_FDCWD, srcPath, AT_FDCWD, tgtPath, RENAME_NOREPLACE) == 0) ^~~~~~~~ QT_GETCWD /home/paul/raspi/qt-everywhere-src-5.11.2/qtbase/src/corelib/io/qfilesystemengine_unix.cpp: At global scope: /home/paul/raspi/qt-everywhere-src-5.11.2/qtbase/src/corelib/io/qfilesystemengine_unix.cpp:115:12: warning: ‘int statx(int, const char*, int, unsigned int, statx*)’ defined but not used [-Wunused-function] static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struct statx *statxbuf) ^~~~~ /home/paul/raspi/qt-everywhere-src-5.11.2/qtbase/src/corelib/io/qfilesystemengine_unix.cpp:109:12: warning: ‘int renameat2(int, const char*, int, const char*, unsigned int)’ defined but not used [-Wunused-function] static int renameat2(int oldfd, const char *oldpath, int newfd, const char *newpath, unsigned flags) ^~~~~~~~~ Makefile:30263: recipe for target '.obj/qfilesystemengine_unix.o' failed make[3]: *** [.obj/qfilesystemengine_unix.o] Error 1 make[3]: Leaving directory '/home/paul/raspi/qt5build/qtbase/src/corelib' Makefile:224: recipe for target 'sub-corelib-make_first' failed make[2]: *** [sub-corelib-make_first] Error 2 make[2]: Leaving directory '/home/paul/raspi/qt5build/qtbase/src' Makefile:48: recipe for target 'sub-src-make_first' failed make[1]: *** [sub-src-make_first] Error 2 make[1]: Leaving directory '/home/paul/raspi/qt5build/qtbase' Makefile:81: recipe for target 'module-qtbase-make_first' failed make: *** [module-qtbase-make_first] Error 2 Please can anyone help here ?
-
I resolved my issue by adapting the configure statement at [link text]https://forum.qt.io/topic/91294/qt-on-raspberry-pi3/9(link url)
My final configure statement read:
../qt-everywhere-src-5.11.2/configure -opengl es2 -device rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /home/paul/raspi/sysroot -opensource -confirm-license \ -I/home/paul/raspi/sysroot/usr/include/ \ -L/home/paul/raspi/sysroot/usr/lib/arm-linux-gnueabihf -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v -no-use-gold-linker -nomake examples -no-compile-examples -nomake tests \ -sql-mysql MYSQL_INCDIR=/home/paul/raspi/sysroot/usr/include/mysql \ MYSQL_LIBDIR=/home/paul/raspi/sysroot/usr/lib/arm-linux-gnueabihf \ -skip qtserialbus -skip qtscxml -skip qtscript -skip qtcharts -skip qt3d \ -skip qtdatavis3d -skip qtcanvas3d -skip qtgamepad -skip qtvirtualkeyboard \ -skip qtwayland -skip qtwebengine -skip qtwebchannel -skip qtwebglplugin \ -skip qtwebsockets --recheck-all
I then needed to build my bluetooth module separately using a FRESH copy of qt-everywhere-src-5.11.2:
Before being able to build and compile the bluetooth module I found I needed to add some paths so qmake can find the headers and libraries.
~/raspi/qt5/bin/qmake -query
gives a list of values for the properties of qmake in the new directory ~/raspi/qt5
including QMAKE_XSPEC:devices/linux-rasp-pi3-g++
With that information the relevant qmake.conf file can be found : ~/raspi/qt5/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf
This can then be edited so that qmake can find the relevant header and library files in sysroot (assuming they are there of course)
INCLUDEPATH+=/home/paul/raspi/sysroot/usr/include LIBS +=-L/home/paul/raspi/sysroot/usr/lib/arm-linux-gnueabihf
After the file is edited, simply run ~/raspi/qt5/bin/qmake in the required module directory in my case 'qtconnectivity'
Then issue the commands
make -j
make install
Finally sync the newly created qt5pi directory with the one on the pi.
rsync -avz qt5pi pi@192.168.1.18:/usr/local
QT creator then configured and I was able to compile my app for the pi knowing far more about the cross compile process.
I
-
Great, thanks for sharing the solution!
Please consider updating the wiki with your new info. https://wiki.qt.io/RaspberryPi2EGLFS
-
@flemingp Sorry for bumping, but I have exactly the same problem - I'm trying to cross-compile qt5 for raspberry pi and encounter error
io/qfilesystemengine_unix.cpp: In function ‘int qt_statx(const char*, statx*)’: io/qfilesystemengine_unix.cpp:321:26: error: ‘AT_FDCWD’ was not declared in this scope 321 | return qt_real_statx(AT_FDCWD, pathname, 0, statxBuffer); | ^~~~~~~~ io/qfilesystemengine_unix.cpp: In function ‘int qt_lstatx(const char*, statx*)’: io/qfilesystemengine_unix.cpp:326:26: error: ‘AT_FDCWD’ was not declared in this scope 326 | return qt_real_statx(AT_FDCWD, pathname, AT_SYMLINK_NOFOLLOW, statxBuffer); | ^~~~~~~~ io/qfilesystemengine_unix.cpp:326:46: error: ‘AT_SYMLINK_NOFOLLOW’ was not declared in this scope 326 | return qt_real_statx(AT_FDCWD, pathname, AT_SYMLINK_NOFOLLOW, statxBuffer); | ^~~~~~~~~~~~~~~~~~~ io/qfilesystemengine_unix.cpp: In function ‘int qt_fstatx(int, statx*)’: io/qfilesystemengine_unix.cpp:331:34: error: ‘AT_EMPTY_PATH’ was not declared in this scope 331 | return qt_real_statx(fd, "", AT_EMPTY_PATH, statxBuffer); | ^~~~~~~~~~~~~ io/qfilesystemengine_unix.cpp: In static member function ‘static bool QFileSystemEngine::renameFile(const QFileSystemEntry&, const QFileSystemEntry&, QSystemError&)’: io/qfilesystemengine_unix.cpp:1447:19: error: ‘AT_FDCWD’ was not declared in this scope 1447 | if (renameat2(AT_FDCWD, srcPath, AT_FDCWD, tgtPath, RENAME_NOREPLACE) == 0) | ^~~~~~~~
However, I don't understand your soultion. My configure script is:
./configure -release -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /mnt/linux_hdd/sysroot -opensource -confirm-license -I/mnt/linux_hdd/sysroot/usr/include/ -L/mnt/linux_hdd/sysroot/usr/lib/arm-linux-gnueabihf -skip qtserialbus -skip qtscxml -skip qtscript -skip qtcharts -skip qt3d -skip qtdatavis3d -skip qtcanvas3d -skip qtgamepad -skip qtvirtualkeyboard -skip qtwayland -skip qtwebengine -skip qtwebchannel -skip qtwebglplugin -skip qtwebsockets -make libs -prefix /usr/local/qt5pi -extprefix /mnt/linux_hdd/qt_rasp/qt5pi -hostprefix /mnt/linux_hdd/qt_rasp/qt5 -no-use-gold-linker -v -no-gbm
You said that after running configure you ran
~/raspi/qt5/bin/qmake -query
Yeah... except there's nothing inside my hostprefix directory. /mnt/linux_hdd/qt_rasp is empty. I've found the qmake binary inside qt-everywhere-src-5.15.1/qtbase/bin.
I've also added
INCLUDEPATH+=/mnt/linux_hdd/sysroot/usr/include/ LIBS +=-L/mnt/linux_hdd/sysroot/usr/lib/arm-linux-gnueabihf
to qtbase/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf.
No difference. Compilation still fails with the same error.
I'm really losing my mind because I can't find a solution.
Would be really thankful for any suggestions