QT on embedded Linux

QT is a very powerful and easy to use C++ library. Usually people think, that it is only good for cross-platform GUI development, but it has also a lot of features, that help in the development of measurement and control software on embedded Linux devices, that don't have any GUI.


We only want to use the following modules:


Installing QT for ARM

Download the QT sources:

cd ~
mkdir 00Software
cd 00Software
wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.4.tar.gz
tar xzf qt-everywhere-opensource-src-4.7.4.tar.gz
rm qt-everywhere-opensource-src-4.7.4.tar.gz
cd qt-everywhere-opensource-src-4.7.4

Tell qmake to use the arm compiler.

Edit the file mkspecs/qws/linux-arm-g++/qmake.conf, so that it looks like this:

# Get the application to invoke the dynamic linker from the CodeSourcery sysrootl
QMAKE_LFLAGS += -Wl,--dynamic-linker=/sysroot/lib/ld-linux.so.3
# modifications to g++.conf
QMAKE_CC                = arm-none-linux-gnueabi-gcc
QMAKE_CXX               = arm-none-linux-gnueabi-g++
QMAKE_LINK              = arm-none-linux-gnueabi-g++
QMAKE_LINK_SHLIB        = arm-none-linux-gnueabi-g++

QMAKE_RPATHDIR = /sysroot/lib:/sysroot/usr/lib:/usr/local/Trolltech/QtEmbedded-4.7.4-arm/lib:/usr/local/Google/protobuf-2.4.1-arm/lib
# modifications to linux.conf
QMAKE_AR                = arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY           = arm-none-linux-gnueabi-objcopy
QMAKE_STRIP             = arm-none-linux-gnueabi-strip

Run ./configure. To see the options, that are available, type:

cd ../../..
./configure -embedded -help

Select the options, that you want, e.g.:

./configure -opensource -confirm-license -no-qt3support -release -nomake examples -nomake demos -no-multimedia -no-phonon -no-webkit -no-gui -no-cups -no-largefile -embedded arm -little-endian -xplatform qws/linux-arm-g++

Compile and install QT for ARM:

make -j2
sudo make install

For convenient cross-compiling from the command line, enter:

cd /usr/local/Trolltech/QtEmbedded-4.7.4-arm/bin
sudo cp qmake qmake-arm
cd ~

joe .bashrc
Add the line:
export PATH=$PATH:/usr/local/Trolltech/QtEmbedded-4.7.4-arm/bin

close terminal
restart terminal

You should now be able to compile QT console programs for ARM with the command sequence:


Simple console program (main.cpp):

#include <QtCore/QCoreApplication>
#include <QDebug>
#include <QTimer>

int main(int argc, char *argv[])
    QCoreApplication app(argc, argv);
    qDebug() << "Hello World!";
    QTimer::singleShot(50, &app, SLOT(quit())); //stop after 50 ms
    return app.exec();

To compile this, you need the follwoing project file (HelloWorld_QT.pro):

QT       += core
QT       -= gui
QT       -= network

TARGET = HelloWorld_QT
CONFIG   += console
CONFIG   -= app_bundle


SOURCES += main.cpp

Back to FrontPage

KielTech: QT on embedded Linux (last edited 2012-01-21 13:06:34 by UweFechner)