Linux sur PDA

Programmation pour OPIE

HelloWorld

Nous allons voir comment faire un petit programme pour OPIE.

Tout d'abord, vous devez avoir le SDK pour OPIE.

Ensuite, sur votre PC, créer votre fichier HelloWorld.cpp avec le code suivant :


#include <qpe/qpeapplication.h>  
#include <qpushbutton.h>  
int main( int argc, char **argv ){    
	QPEApplication a( argc, argv );
	QPushButton hello( "Hello world!", 0 ); 
	hello.resize( 100, 30 );
	a.setMainWidget( &hello );
	hello.show();
	return a.exec();  
}

Il s'agit du code qui permettra d'afficher HelloWorld sur votre PDA.

Ensuite, vous allez créer un fichier qui permettra à votre programme d'être compilé : HelloWorld.pro


TEMPLATE = app
CONFIG  += qt warn_on release
DESTDIR  = $(OPIEDIR)/bin
HEADERS  =
SOURCES  = myhello.cpp
TARGET  = myhello
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS  += -lqpe
include ( $(OPIEDIR)/include.pro )

Vous devez ensuite renseigner certaines variables :


export OPIEDIR = YourOpieDir
export QTDIR = YourQTDir
export QMAKESPEC = $OPIEDIR/mkspecs/qws/arm-linux-g++

Nous allons à présent créer le makefile à partir du fichier .pro :


qmake -o Makefile myhello.pro

Il ne reste plus qu'à compiler votre programme grâce ą la commande make.

Il est possible de faire un fichier de configuration de votre programme : HelloWorld.desktop


[Desktop Entry]
Comment=Myhello App
Exec=myhello
Icon=myhello_icon
Type=Application
Name=Myhello

Il suffit de copier le fichier de configuration ainsi que l'executable sur votre PDA et voilą !