Skip to content

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
This is a recipe, here is a simple content for our project (download it here):

DESCRIPTION = "Small Qt Hello World!"
PR = "r0"

S = "${WORKDIR}/${P}"

SRC_URI = "file://HelloWorldQt.tar"

FILES_${PN} = "${libdir}/qt4"

inherit qt4e cmake

                 -DQT_INSTALL_LIBS=${OE_QMAKE_LIBDIR_QT} \
                 -DQT_INCLUDE_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_DBUSXML2CPP_EXECUTABLE=/usr/bin/qdbusxml2cpp \
                 -DQT_DBUSCPP2XML_EXECUTABLE=/usr/bin/qdbuscpp2xml \


# Adding our bin file to the main package
FILES_${PN} = "${bindir}/*"

The final architecture for your project in OE should be something like this:


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:


Then the module should work fine.

Pages: 1 2 3

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Click to Insert Smiley

SmileBig SmileGrinLaughFrownBig FrownCryNeutralWinkKissRazzChicCoolAngryReally AngryConfusedQuestionThinkingPainShockYesNoLOLSillyBeautyLashesCuteShyBlushKissedIn LoveDroolGiggleSnickerHeh!SmirkWiltWeepIDKStruggleSide FrownDazedHypnotizedSweatEek!Roll EyesSarcasmDisdainSmugMoney MouthFoot in MouthShut MouthQuietShameBeat UpMeanEvil GrinGrit TeethShoutPissed OffReally PissedMad RazzDrunken RazzSickYawnSleepyDanceClapJumpHandshakeHigh FiveHug LeftHug RightKiss BlowKissingByeGo AwayCall MeOn the PhoneSecretMeetingWavingStopTime OutTalk to the HandLoserLyingDOH!Fingers CrossedWaitingSuspenseTremblePrayWorshipStarvingEatVictoryCurseAlienAngelClownCowboyCyclopsDevilDoctorFemale FighterMale FighterMohawkMusicNerdPartyPirateSkywalkerSnowmanSoldierVampireZombie KillerGhostSkeletonBunnyCatCat 2ChickChickenChicken 2CowCow 2DogDog 2DuckGoatHippoKoalaLionMonkeyMonkey 2MousePandaPigPig 2SheepSheep 2ReindeerSnailTigerTurtleBeerDrinkLiquorCoffeeCakePizzaWatermelonBowlPlateCanFemaleMaleHeartBroken HeartRoseDead RosePeaceYin YangUS FlagMoonStarSunCloudyRainThunderUmbrellaRainbowMusic NoteAirplaneCarIslandAnnouncebrbMailCellPhoneCameraFilmTVClockLampSearchCoinsComputerConsolePresentSoccerCloverPumpkinBombHammerKnifeHandcuffsPillPoopCigarette