Hello World in Qt using CMake and OpenEmbedded
Cooking with OpenEmbedded
For that matter, it happen that you are interested in Qt for embedded application, and you are using OpenEmbedded to build a nice custom distribution.
It would be great if your Qt application could be that image. Hopefully, we can sure build a recipe do to so.
Go to your OpenEmbedded repository, and then to the recipes/ directory.
Create a subfolder, called “helloworldqt” for example. Try to respect the name policy: lower cases, no spaces, no weird char (avoid _ especially).
Create a file, a usual template is {project}_{version}.bb, in our case helloworldqt_1.0.0.bb.
This is a recipe, here is a simple content for our project (download it here):
DESCRIPTION = "Small Qt Hello World!"
LICENSE = "GPL"
PR = "r0"
S = "${WORKDIR}/${P}"
SRC_URI = "file://HelloWorldQt.tar"
FILES_${PN} = "${libdir}/qt4"
inherit qt4e cmake
EXTRA_OECMAKE = "-DQT_LIBRARY_DIR=${OE_QMAKE_LIBDIR_QT} \
-DQT_INSTALL_LIBS=${OE_QMAKE_LIBDIR_QT} \
-DQT_INCLUDE_DIR=${OE_QMAKE_INCDIR_QT} \
-DQT_HEADERS_DIR=${OE_QMAKE_INCDIR_QT} \
-DQT_MOC_EXECUTABLE=${OE_QMAKE_MOC} \
-DQT_UIC_EXECUTABLE=${OE_QMAKE_UIC} \
-DQT_UIC3_EXECUTABLE=${OE_QMAKE_UIC3} \
-DQT_RCC_EXECUTABLE=${OE_QMAKE_RCC} \
-DQT_QMAKE_EXECUTABLE=${OE_QMAKE_QMAKE} \
-DQT_QTCORE_INCLUDE_DIR=${OE_QMAKE_INCDIR_QT}/QtCore \
-DQT_DBUSXML2CPP_EXECUTABLE=/usr/bin/qdbusxml2cpp \
-DQT_DBUSCPP2XML_EXECUTABLE=/usr/bin/qdbuscpp2xml \
-DQT_MKSPECS_DIR=${QMAKESPEC}/../ \
"
OECMAKE_SOURCEPATH = "../HelloWorldQt"
# Adding our bin file to the main package
FILES_${PN} = "${bindir}/*"
The final architecture for your project in OE should be something like this:
helloworldqt/ helloworldqt/files/HelloWorldQt.tar hellowroldqt/helloworldqt_1.0.0.bb
Here is a tricky part, CMake is using a file called FindQt4.cmake to look for Qt4 libraries, while it would work with the qt4x11 of Qt, Qt4-embedded produce libraries that end with an E, making it inefficient only because of that missing E.
Since the problem has been corrected in a more recent version of cmake, another cleaner solution is to download the last version of the FindQt4.cmake file here and to replace yours. This will also work if you have a native cmake (as long as your version is recent enough to handle stuff in that .cmake file).
Otherwise, you can change add the E manually (dirty). If you use a cmake from OE (ie you didn’t ASSUME cmake-native in your local.conf), just edit the file /oetmp/staging/i686-linux/usr/share/cmake-2.6/Modules/FindQt4.cmake.
Line 696, add ${QT_MODULE}E, it should look something like this:
NAMES ${QT_MODULE} ${QT_MODULE}4 ${QT_MODULE}E
Then the module should work fine.