Skip to content

Hello World in Qt using CMake and OpenEmbedded

Let’s compile !

By default, compiling Qt programs rely on qmake. Since this is not standard C++, few steps needs to be done before our project can be handled by regular compilers like gcc or mvc.
In order to that, you can do a .pro file and describe your project, qmake will handle it and give you a nice executable file.

When you are using other libraries, CUDA, stuff like that, doing that all that with qmake gets tricky.
Let’s use CMake instead ! It’s way much powerful, portable, simple, etc …

Here is a simple CMakeLists.txt for our program:

#include <QtGui/QApplication>
#include "MainWindow.h"
 
int main(int argc, char *argv[])
{
 QApplication a(argc, argv);
 MainWindow w;
 w.show();
 return a.exec();
}

An overall view on what cmake is going to do is that it will first ask qmake to handle all Qt files, and then it will compile the sources, along with some files produced by qmake, and finally link all things together.

On Linux or Mac, simply do this commands in the directory where there is your sources:

cmake .
make
./HelloWorldQt

It’s likely to work by doing so if your Qt installation is correct (meaning that qmake is in your path, and LD_PATH too).

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