GUF-Yocto-jethro-9.0-r7707-0
i.MX6
User Manual
{
cout << "Hello World!" << endl;
return 0;
}
Edit the contents of the
Makefile
as follows:
myapp: main.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
$(STRIP) $@
clean:
rm -f myapp *.o *~ *.bak
It is necessary to setup your build environment so that the complier, headers and libraries can be found. This is
done by "sourcing" a build environment configuration file. If the toolchain is installed in the default directory, this
example compiles for the target system by typing
$ source
,!
/opt/guf/GUF-Yocto-jethro-9.0-r7707-0-sdk/environment-setup-imx6guf-guf-linux-gnueabi
$ make
in the
myapp
directory. The first line is needed only once as it configures the current shell and sets the necessary
environment variables.
After a successful build, the
maypp
executable is created in the
myapp
directory. You can transfer this application
to the target system’s
/usr/bin
directory using one of the ways described in chapter
[
I
and execute it from the device shell. It might be necessary to change the access rights of the executable
first, so that all users are able to execute it.
You can find further information about how to build applications for Yocto-based platforms at:
https://www.yoctoproject.org/docs/current/adt-manual/adt-manual.html
7.3
Qt-based GUI user application
Create a new directory in your home directory on the host system and change to it:
$ cd ~
$ mkdir myqtapp
$ cd myqtapp
Create the empty files
main.cpp
and
myqtapp.pro
.
$ touch main.cpp myqtapp.pro
Edit the contents of the file
main.cpp
as follows:
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setOverrideCursor(Qt::BlankCursor);
QPushButton hello("Hello World!");
hello.setWindowFlags(Qt::FramelessWindowHint);
hello.resize(800, 480);
hello.show();
return app.exec();
}
Edit the contents of the file
myqtapp.pro
as follows:
49