Qt Commercial Support Weekly #17 - Getting started with QNX on Windows

With the release of Qt Commercial 4.8.1 came the official support for QNX which had been in Beta in the Qt Commercial 4.8.0 release.  Now that it is officially supported we have released a pre-built version of Qt Commercial for QNX that can be used for cross-compiling your application on Windows.  This is in addition to the standard source package, which you can download yourself to build on Linux, currently it is only possible to use the pre-built version if you want to develop on Windows for QNX.

 

First of all, to obtain the pre-built version you need to download the Qt Commercial SDK, if you already have this downloaded then you don't need to download it again, just start it up as it will check for the latest packages for you and subseqently offer you the QNX one, if applicable.  All that needs to be done after this is to install the QNX binaries for Windows and this will be placed inside your Qt Commercial SDK directory.

 

Once this is done there are a few more things you need to do currently in order to be able to build your application for QNX.  You can either build on the command line or inside Qt Creator as you would normally, but there are a couple of things you need to do in addition to get it to build for QNX on Windows.

 

Assuming that your environment is already set so that it has the qnxbin directory in your PATH and when running qmake on the pro file for the application,  then you need to specify the -spec argument so that it refers to the qnx one.  On the command line, add teh following to the list of arguments that you use when you call qmake:

 

  -spec qws/qnx-armv7-g++

 

Once that has finished, then you can use make to make the application. After that it is ready to be deployed, you can just copy the built application with the Qt libraries to the QNX device for testing.

 

If you want to use Qt Creator, then you need to setup a few more things as it needs to be informed about the toolchain and also the Qt version.  To fix this in Qt Creator go to Tools | Options | Build & Run | Qt Versions.  If the Qt version for QNX does not exist in the auto-detected list, then click on Add to add the version.  The path will be something like:

 

   C:qtcommercialsdkembeddedqnx481armv7binqmake.exe

 

Then click on Tool Chains and click on Add selecting MinGW from the pulldown list.  Set the compiler path to be:

 

  C:QNX650hostwin32x86usrbinntoarmv7-gcc.exe

 

Then double-click on the MinGW entry in the name column and change it to be QNX.  Now the toolchain and Qt version is set up so all that is left to be done is to set up your project to be built for QNX.  Once you get your project open, then go to the Project tab on the side of Qt Creator.  If you have an Embedded Linux Target set up for it, then you can change the settings for this target, otherwise you can do the same changes for the target you have set.  First of all, you need to ensure that the Qt version used is the one for QNX.  Then, click on the details button next to qmake and make in the Build Steps section and on the details button next to make in the Clean Steps section.  In the additional arguments settings for qmake then add:

 

  -spec qws/qnx-armv7-g++

 

Where it says Override mingw32-make.exe (in the make and Clean Steps sections) then put:

 

   C:QNX650hostwin32x86usrbinmake.exe

 

Now you are done, your project can be built inside Qt Creator for QNX.  Again, you will need to deploy it manually by copying the executable and the Qt libraries to the QNX device for testing.

 

In the future, we plan to have better support for this inside Qt Creator, but at least it is fairly straightforward to get up and running with this.  As always, if you encounter any problems then please contact support via the customer portal and until next time, happy coding :)


Comments