Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
OpenWRT QT5.7.0 static compilation
gustav nilsson last edited by gustav nilsson
So, ive been at this thing now for about 3 weeks, so i thought id turn in for some help.
Basically i want to run my QT5.7 project on a linksys WRT1200 router. The project works fine on the desktop, builds fine with qmake and make and runs perfectly.
The router has about 28MB of storage, runs armv7l and has a limited busybox (1.23.2) for issuing linux commands. Compilation on this box would take centuries to say the least, not to mention other implications; no make, hdd space, ram shortage etc. The package manager (opkg) also has no reference to qt5, so there will be no cheating there.
For reference my desktop runs xubuntu.
So i need qt5 to run on this device. The steps ive taken are listed below;
1.1: First i compiled a compiler (guide found here: http://telecnatron.com/articles/Cross-Compiling-For-OpenWRT-On-Linux/)
1.2: I also configured and installed qt5.7.0 from git using "./configure -release -opensource -confirm-license -static -no-largefile -no-qml-debug -qt-xcb -developer-build -opengl es2 -skip wayland -skip declarative -nomake examples -nomake tests" and "make"
1.3: Now i tried to simply set up qmake with the QMAKE_CXX, QMAKE_CC, CONFIG += static flags to use this compiler (arm-openwrt-linux-g++/gcc). This resulted in two errors with ld; Relocations in generic ELF (EM: 40) and error adding symbols: File in wrong format. I think this has todo with qt not installed proper static, but i dont know, maybe i am missing something.
2: I tried to decipher the instructions at http://doc.qt.io/QtForDeviceCreation/qtee-static-linking.html but failed at creating my own mkspec located at "qtbase/mkspecs/arm-openwrt-linux-g++". I based my mkspec on the linux-arm-gnueabi-g++ mkspec thinking that they were alike, but i still get error messages (Error: No device matching 'arm-openwrt-linux-g++') when configuring qt with;
"/home/gustav/opt/qt5/qtbase/configure -top-level -release -opensource -confirm-license -static -no-largefile -no-qml-debug -qt-xcb -developer-build -opengl es2 -skip wayland -skip declarative -nomake examples -nomake tests -hostprefix /home/gustav/opt/qt5-openwrt -device arm-openwrt-linux-g++ -device-option CROSS_COMPILE=/home/gustav/crosscompile/openwrt/staging_dir/toolchain-arm_mpcore+vfp_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux- -sysroot /home/gustav/crosscompile/openwrt/staging_dir/qt5-openwrt"
3: Im thinking of running armv7l openwrt in qemu (or any generic virtualization software, tips appreciated), this is a prospect i haven't pursued yet due to doubts. This way i could give the machine a whole heap of resources, but i would still have to compile things like make, gnuutils etc.
So, what have i done wrong, alternatively what approach should i take? I have scoured the interwebs for information but there might be posts ive missed.
Any help is greatly appreciated!
edit: im trying to fix this for the openwrt 15.05.1 "chaos calmer"
not help, just out of curiosity.
Why, why, why do you want to run Qt on such a limited device???
I mean what are the benefits? I guess you just want to use the utility classes out of convenience?
So about 95% of the Qt framework are not needed, but still the whole binary is loaded into the RAM (since you built static) which anyway is limited by 28MB !!!!
You are way better off holding your code base minimal and use the tools available and if they are not use some minimalistic 3rd-party libraries for the tasks.
gustav nilsson last edited by
Thank you for your reply @raven-worx =)
QT is kinda awesome, especially for networking, which the purpose of the project. To my knowledge alot of QTs functionality can be skipped when configuring. Also only using QTBase, core and networking when compiling would bring down the projects size.
Maybe you are correct in using other tooling, i will take it into consideration.
i think Qt is a dead-end here. Using the standard/native socket API consumes nothing on the device and isn that hard to use, you just might need some reading on it.
gustav nilsson last edited by
Thank you for perspective @raven-worx, however i would really like to know if this is possible. Porting the codebase to use anything else than QT will be a whole heap of work, talking months, and im not ready to give up on cross compiling QT for this device yet.
and im not ready to give up on cross compiling QT for this device yet.
then i wish you good luck ;)
Then the only way I see possible is to make a custom Qt build where you remove everything that you don't use. Take a look at the new configuration system from Qt 5.8 to make your own lightweight version of Qt.
Hope it helps