compiling qt apps

Post on 09-May-2015

1.049 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Compiling  Qt  -­‐  apps  

Jussi  Pohjolainen  Tampere  University  of  Applied  Sciences  

source.cpp  #include <QtWidgets>

int main(int argc, char *argv[]){ QApplication a(argc, argv);

QLabel b; b.setText("moi"); b.show();

return a.exec();}

Crea@ng  Project  

•  Create  new  projecBolder  and  save  the  source.cpp  into  the  folder  – /QtHelloWorld/source.cpp

•  Create  plaBorm  independent  project  file  – qmake –project

•  Creates  – /QtHelloWorld/QtHelloWorld.pro

pro?  ###################################################################### # Automatically generated by qmake (3.0) ke maaliskuuta 4 10:34:14 2015

######################################################################

TEMPLATE = app

TARGET = QtHelloWorld

INCLUDEPATH += .

# add this!

QT += widgets

# Input

SOURCES += source.cpp

qmake  

•  AGer  building  the  project  –  file,  we  well  create  a  pla$orm  specific  makefile  

•  makefile  =  informa@on  how  to  build  the  target  program  (compile  instruc@ons)  

•  In  Mac  OS  X,  the  qmake  creates  automa@cally  Xcode  –  project  files.  Use:  qmake -spec macx-g++

•  In  other  systems,  qmake should  be  enough.  

qmake  usage  on  Mac  OS  X  

make  and  running  

•  make  will  compile  the  applica@on  using  the  instruc@ons  in  the  makefile  

•  AGer  compila@on  you  can  run  the  applica@on  

Compiling  and  Running  

Build  Steps  

•  qmake –project – Creates  plaBorm  independent  project  file  

•  qmake – Creates  plaBorm  specific  makefile  

•  make – Compiles  the  applica@on  

•  ./helloworld – Starts  the  app  (depends  on  the  plaBorm)  

top related