QNX-App-development-and-deployment

From Qt Wiki
Revision as of 16:37, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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”.

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:

  1. 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.
  1. 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”:

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:

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 NFS [en.wikipedia.org] 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

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

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

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):

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:

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”:

The build process can then simply be started with:

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 this link [qnx.com] 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.

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 [en.wikipedia.org], you have to point the Qt runtime to the location of the Qt fonts in “<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 slogger2-framework [qnx.com] by default. This framework provides by far a better performance that text logs on flash file systems, has categorization and some other additional facilities.

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.

Categories: