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

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Qt application development and deployment on <span class="caps">QNX</span>=


Application development using <span class="caps">QNX</span> 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 <span class="caps">QNX</span> 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 [[Setting-up-Qt-Creator-for-QNX|QtCreator for development]].
==Connecting to a <span class="caps">QNX</span> board==
Once the <span class="caps">QNX</span> 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:
# You copy the Qt runtime to a persistent storage on the target board, e.g a folder on the SD card, internal flash or <span class="caps">USB</span> 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 <span class="caps">NFS</span>. 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 <span class="caps">QNX</span> board) we only need libraries plugins and qml imports from the Qt5 installation. These three folders (“lib”, “plugins”, “qml”) should be copied to the <span class="caps">QNX</span> 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 <span class="caps">NFS</span>===
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 <span class="caps">NFS</span>] ''[en.wikipedia.org]'' on the <span class="caps">QNX</span> board. This has the advantage that the files don’t have to be copied over to the <span class="caps">QNX</span> file system on the target and remain on the development PC, from where they can be edited and changed any time.
====Setting up <span class="caps">NFS</span>====
A <span class="caps">NFS</span> 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 <span class="caps">NFS</span> e.g.:
to “/etc/exports”. Afterwrads the <span class="caps">NFS</span> server has to be restarted.
Note: that this <span class="caps">NFS</span> export has as much as no security measures set. If this aspect matters, please change the configuration accordingly.
=====Mounting <span class="caps">NFS</span>=====
On the <span class="caps">QNX</span> board you can now mount the folder to “/home/user/development” (&lt;host-ip&gt; is the IP address of your host machine):
==Application development==
Developing a Qt5 application with <span class="caps">QNX</span> 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 <span class="caps">QML</span> files, and/or Qt resource (.qrc) and asset (images, sounds, etc) files.
===Compilation===
Before starting a build, make sure to “source” the <span class="caps">QNX</span> environment script:
Before compiling the application, '''qmake''' (the one from the Qt5 for <span class="caps">QNX</span> 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 <span class="caps">QNX</span> filesystem (with all asset/media files) or be located in a folder mounted over <span class="caps">NFS</span>. The application binary can then be simply executed from a remote shell on the target. There are two preconditions:
* The <span class="caps">QNX</span> 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] ''[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 <span class="caps">QNX</span> board:
* “LD_LIBRARY_PATH” should be set to “&lt;path-to-the-destination-folder&gt;/lib”
* “QT_PLUGIN_PATH” defines where the Qt plugins are located. It should be set to “&lt;path-to-the-destination-folder&gt;/plugins”
* “QML2_IMPORT_PATH” defines where the Qt Quick 2 / QML2 plugins are located. It should be set to “&lt;path-to-the-destination-folder&gt;/qml”
* <span class="caps">QML</span>_IMPORT_PATH” is required only when using the QtQuick1 compatibility module. It should be set to “&lt;path-to-the-destination-folder&gt;/imports”
The &lt;path-to-the-destination-folder&gt; 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 <span class="caps">NFS</span> as discussed above.
Addtionally, the Screen requires the “<span class="caps">QQNX</span>_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 <span class="caps">QNX</span> 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] ''[en.wikipedia.org]'', you have to point the Qt runtime to the location of the Qt fonts in “&lt;path-to-the-destination-folder&gt;/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] ''[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 <span class="caps">QNX</span> 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 “<span class="caps">QSG</span>_FIXED_ANIMATION_STEP” environmental variable to “no”, or use a custom animation driver.
===Categories:===
* [[:Category:QNX|QNX]]

Revision as of 07:44, 24 February 2015