12. Developping QNX Ada projects

12.1. Creating QNX projects containing Ada code

12.1.1. Audience

This document is intended for users already somewhat familiar with QNX Momentics, and GNATbench. Some familiarity with GNAT cross compilers may also be useful.

12.1.2. Before You Begin

Install Ada cross-compiler toolchain for QNX.

On linux at the end of the install process, you’ll be asked to update your environment, to add cross compiler binaries path to PATH variable for example. Update your environment, prior to launch QNX Momentics and use GNATbench menus.

You can check correct cross compiler installation displaying Ada/Toolchains preferences page. QNX installed toolchains should be displayed without any error decorator.

At startup GNATbench automatically create and fill “Ada runtime libraries for QNX” project. The libraries copied in this project will be automatically uploaded into QNX target when a QNX project linked dynamically to Ada runtime is launched on the target.

This project creation/update can be disabled through Ada/QNX preferences page.

If Ada runtime libraries are not made visible to QNX loader ‘ldd:FATAL: Could not load library libgnat-19.so’ errors will be reported when launching such QNX executables. Important

You cannot create directly a QNX project containing Ada code. You need first to create an empty QNX project, and then convert it to a QNX executable or shared/static library project using “Ada/Convert an empty QNX Project to use Ada Language” wizard.

12.1.3. Create the Empty QNX Project that will contain Ada code

We will create a new QNX project using the wizard via File -> New -> Project and then selecting QNX Project as shown below.


Press Next.

This brings up the first wizard page. As shown below, we have selected “Empty QNX Project” template.


Press Next.

This brings up the last wizard page. As shown below, we have provided a name for the empty QNX project we will create. Select C++ language if you plan to put C++ code in your project, otherwise you can keep C language selection. Select the CPU variant of the cross compilers you have installed.


Press Finish

The QNX project is created. Ignore the “No rule to make target ‘all’” problem.

12.1.4. Convert the empty QNX project to use Ada language

We will add Ada language use to this empty QNX project using the wizard via File -> New -> Other... and then selecting Convert an empty QNX Project to use Ada Language as shown below.


Press Next

Set the name of executable or library you want to create. It has to be an Ada valid identifier starting with a letter and containing only ‘a-z’, ‘0-9’ and ‘_’ characters.

Select the type of QNX project you want to build.


Press Finish to launch project conversion.

Once created, run Build Project menu to verify that the project can be built.

If you have asked for a QNX executable, you can run it on your QNX target. The ‘Hello World!’ string is displayed in the Console view