QNX-App-development-and-deployment: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Add "cleanup" tag)
(Convert ExpressionEngine links)
Line 41: Line 41:
=== Mounting Qt5 over NFS ===
=== Mounting Qt5 over NFS ===


A very convenient way to work with Qt5 during the development process is to mount the Qt5 installation directory (that is on your host PC) via "NFS":http://en.wikipedia.org/wiki/Network_File_System on the QNX board. This has the advantage that the files don't have to be copied over to the QNX file system on the target and remain on the development PC, from where they can be edited and changed any time.
A very convenient way to work with Qt5 during the development process is to mount the Qt5 installation directory (that is on your host PC) via [http://en.wikipedia.org/wiki/Network_File_System NFS] on the QNX board. This has the advantage that the files don't have to be copied over to the QNX file system on the target and remain on the development PC, from where they can be edited and changed any time.


==== Setting up NFS ====
==== Setting up NFS ====
Line 95: Line 95:
Once the application is built it must either be deployed (i.e. copied) to the QNX filesystem (with all asset/media files) or be located in a folder mounted over NFS. The application binary can then be simply executed from a remote shell on the target. There are two preconditions:
Once the application is built it must either be deployed (i.e. copied) to the QNX filesystem (with all asset/media files) or be located in a folder mounted over NFS. The application binary can then be simply executed from a remote shell on the target. There are two preconditions:


* The QNX target board already runs the "Screen Graphics Subsystem" (see "this link":http://www.qnx.com/developers/docs/660/topic/com.qnx.doc.screen/topic/manual/cscreen_about.html for details)
* The QNX target board already runs the "Screen Graphics Subsystem" (see [http://www.qnx.com/developers/docs/660/topic/com.qnx.doc.screen/topic/manual/cscreen_about.html this link] for details)
* Qt runtime environment variables are set as described in the next section  
* Qt runtime environment variables are set as described in the next section  


Line 117: Line 117:
It defines the height and width of the app's display area on the screen in millimeters. Some QNX boot images define set this variable on start-up globally.
It defines the height and width of the app's display area on the screen in millimeters. Some QNX boot images define set this variable on start-up globally.


If you have a build which does not use "Fontconfig":http://en.wikipedia.org/wiki/Fontconfig, you have to point the Qt runtime to the location of the Qt fonts in "<path-to-the-destination-folder>/lib/fonts":
If you have a build which does not use [http://en.wikipedia.org/wiki/Fontconfig Fontconfig], you have to point the Qt runtime to the location of the Qt fonts in "<path-to-the-destination-folder>/lib/fonts":


</code>
</code>
Line 127: Line 127:
==== Accessing application logs ====
==== Accessing application logs ====


Application logs from "QDebug" go to the "slogger2-framework":http://www.qnx.com/developers/docs/660/index.jsp?topic=/com.qnx.doc.neutrino.utilities/topic/s/slogger2.html by default. This framework provides by far a better performance that text logs on flash file systems, has categorization and some other additional facilities.
Application logs from "QDebug" go to the [http://www.qnx.com/developers/docs/660/index.jsp?topic=/com.qnx.doc.neutrino.utilities/topic/s/slogger2.html slogger2-framework] by default. This framework provides by far a better performance that text logs on flash file systems, has categorization and some other additional facilities.


In order to retrieve logs you can either launch </code>slog2info -w</code> on the QNX board or install a "custom qt message handler":http://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler that would redirect the logs to the console again.
In order to retrieve logs you can either launch </code>slog2info -w</code> on the QNX board or install a [http://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler custom qt message handler] that would redirect the logs to the console again.


==== If you feel that Qt Quick animations run too slow… ====
==== If you feel that Qt Quick animations run too slow… ====


Qt5 on QNX uses fixed step animation timing. That means it advances the animations by 16ms (if the display refresh rate is 60Hz) per frame, no matter how long a frame takes to render. While this gives perfect results if your application is running at a frame rate equal to display refresh rate (usually 60Hz), this will lead to slow animations when the frame rate drops is is generally slower on a given hardware. If your target can not maintain a constant frame rate consider setting the "QSG_FIXED_ANIMATION_STEP" environmental variable to "no", or use a custom animation driver.
Qt5 on QNX uses fixed step animation timing. That means it advances the animations by 16ms (if the display refresh rate is 60Hz) per frame, no matter how long a frame takes to render. While this gives perfect results if your application is running at a frame rate equal to display refresh rate (usually 60Hz), this will lead to slow animations when the frame rate drops is is generally slower on a given hardware. If your target can not maintain a constant frame rate consider setting the "QSG_FIXED_ANIMATION_STEP" environmental variable to "no", or use a custom animation driver.

Revision as of 15:15, 4 March 2015

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

Qt application development and deployment on QNX

Application development using QNX and Qt5 is as convenient as on other Qt platforms, yet there are some differences the developer should be aware of. This wiki page will briefly walk you through the steps of setting up the environment and configuring a QNX board in to establish an efficient development process. While this page only focuses on the command line, it is also worthwhile to read if you plan to using the QtCreator for development.

Connecting to a QNX board

Once the QNX board has been set up and received a valid IP address, a connection to it can be established using telnet. The username and password are both by default to "root".

> telnet <qnx-board-ip><code>

== Deploying the Qt5 runtime ==

In order make your application to be executable, the Qt5 libraries, plugins and qml import files have to become accessible from the location you want to run the application from. There are two choices for this:

# You copy the Qt runtime to a persistent storage on the target board, e.g a folder on the SD card, internal flash or USB stick.

# The folders with the Qt runtime and/or with binaries of your application on your host machine can also be mounted from the board over NFS. This way is very useful during the daily development process because the files remain on the host PC and can be modified more easily making develop-test cycles very short.

=== Deploying Qt5 to the file system ===

On the target side (i.e. the QNX board) we only need libraries plugins and qml imports from the Qt5 installation. These three folders ("lib", "plugins", "qml") should be copied to the QNX filesystem using, for example, "scp":

> cd <qt-for-qnx-installation-folder> > scp -r lib qml plugins root@my-qnx-board-ip:/path-to-the-destination-folder

Please note that if you have a debug build the runtime reach a size of 1GB. The above command copies all files from the host which is more than actually needed on target. If space matters, delete files which are not needed. Moreover, "scp" follows symbolic links and so copies Qt libraries multiple times. This can increase the size of the runtime as well. You can use "tar" and copy the files via a ssh pipe:

cd <qt-for-qnx-installation-folder> tar cpf- lib qml plugins | ssh -i ~/.ssh/id_rsa root@my-qnx-board-ip tar xpf- -C /path-to-the-destination-folder

The location of the destination folder does not matter as long as it is persistent and can be accessed by applications.

=== Mounting Qt5 over NFS ===

A very convenient way to work with Qt5 during the development process is to mount the Qt5 installation directory (that is on your host PC) via [http://en.wikipedia.org/wiki/Network_File_System NFS] on the QNX board. This has the advantage that the files don't have to be copied over to the QNX file system on the target and remain on the development PC, from where they can be edited and changed any time.

==== Setting up NFS ====

A NFS server has to be installed and running on the host (e.g. the PC your are developing on).

===== Installation on Linux =====

> sudo apt-get install nfs-common nfs-kernel-server

Add the folder you want to export over NFS e.g.:

/home/user/development *(rw,no_root_squash,subtree_check)<code>

to "/etc/exports". Afterwrads the NFS server has to be restarted.

> /etc/init.d/nfs-kernel-server restart

Note: that this NFS export has as much as no security measures set. If this aspect matters, please change the configuration accordingly.

Mounting NFS

On the QNX board you can now mount the folder to "/home/user/development" (<host-ip> is the IP address of your host machine):

> fs-nfs3 <host-ip>:/home/user/development /home/user/development<code>

== Application development ==

Developing a Qt5 application with QNX is not much different from using Qt5 on other platforms. Yet there are some things the developer should be aware of.

=== Setting up a new project ===

A Qt project typically consists of a project file (.pro), sources and headers. Additionally, there might be QML files, and/or Qt resource (.qrc) and asset (images, sounds, etc) files.

=== Compilation ===

Before starting a build, make sure to "source" the QNX environment script:

> source <path-to-the-qnx-sdp>/qnx660-env.sh

Before compiling the application, qmake (the one from the Qt5 for QNX installation you use, and not one from a Qt build for desktop!) has to be executed against your project file and will produce a "Makefile":

> <path-to-the-qt-for-qnx-installation-folder>/bin/qmake my_qt_app.pro

The build process can then simply be started with:

> make<code>

=== Executing the application ===

Once the application is built it must either be deployed (i.e. copied) to the QNX filesystem (with all asset/media files) or be located in a folder mounted over NFS. The application binary can then be simply executed from a remote shell on the target. There are two preconditions:

* The QNX target board already runs the "Screen Graphics Subsystem" (see [http://www.qnx.com/developers/docs/660/topic/com.qnx.doc.screen/topic/manual/cscreen_about.html this link] for details)
* Qt runtime environment variables are set as described in the next section 

==== Setting up the Qt5 environment on the board ====

A Qt5 application needs to be able to find the Qt runtime (libraries, plugins and qml imports) on application start-up. Therefore following environment variables must be set on the QNX board:

* "LD_LIBRARY_PATH" should be set to "<path-to-the-destination-folder>/lib"
* "QT_PLUGIN_PATH" defines where the Qt plugins are located. It should be set to "<path-to-the-destination-folder>/plugins"
* "QML2_IMPORT_PATH" defines where the Qt Quick 2 / QML2 plugins are located. It should be set to "<path-to-the-destination-folder>/qml"
* QML_IMPORT_PATH" is required only when using the QtQuick1 compatibility module. It should be set to "<path-to-the-destination-folder>/imports"

The <path-to-the-destination-folder> is the directory we mentioned above. The one where you copied the Qt5 runtime to the target. This folder can also be a folder mounted over NFS as discussed above.

Addtionally, the Screen requires the "QQNX_PHYSICAL_SCREEN_SIZE" environment variable to be set, e.g.

export QQNX_PHYSICAL_SCREEN_SIZE="150,90"

It defines the height and width of the app's display area on the screen in millimeters. Some QNX boot images define set this variable on start-up globally.

If you have a build which does not use [http://en.wikipedia.org/wiki/Fontconfig Fontconfig], you have to point the Qt runtime to the location of the Qt fonts in "<path-to-the-destination-folder>/lib/fonts":

export QT_QPA_FONTDIR=<path-to-the-destination-folder>/lib/fonts

Note that this is probably not needed in most cases.

==== Accessing application logs ====

Application logs from "QDebug" go to the [http://www.qnx.com/developers/docs/660/index.jsp?topic=/com.qnx.doc.neutrino.utilities/topic/s/slogger2.html slogger2-framework] by default. This framework provides by far a better performance that text logs on flash file systems, has categorization and some other additional facilities.

In order to retrieve logs you can either launch

slog2info -w on the QNX board or install a custom qt message handler that would redirect the logs to the console again.

If you feel that Qt Quick animations run too slow…

Qt5 on QNX uses fixed step animation timing. That means it advances the animations by 16ms (if the display refresh rate is 60Hz) per frame, no matter how long a frame takes to render. While this gives perfect results if your application is running at a frame rate equal to display refresh rate (usually 60Hz), this will lead to slow animations when the frame rate drops is is generally slower on a given hardware. If your target can not maintain a constant frame rate consider setting the "QSG_FIXED_ANIMATION_STEP" environmental variable to "no", or use a custom animation driver.