In this section, we'll describe how to compile and debug a QNX Neutrino system. Your QNX Neutrino system might be anything from a deeply embedded turnkey system to a powerful multiprocessor server. You'll develop the code to implement your system using development tools running on a supported cross-development platform.

QNX Neutrino supports cross-development, where you develop on your host system and then transfer and debug the executable on your target hardware.

Note: You can choose how you wish to compile and link your programs: you can use tools with a command-line interface (via the qcc command) or you can use our Integrated Development Environment (see the IDE User's Guide). Our samples here illustrate the command-line method.

Let's look at the spectrum of methods available to you to run your executable:

If your environment is: Then you can:
Cross-development, network filesystem link Compile and link, load over a network filesystem, and then run on the target
Cross-development, debugger link Compile and link, use a debugger to transfer the executable to the target, and then run on the target
Cross-development, rebuilding the image Compile and link, rebuild the entire image, and then reboot the target.

Which method you use depends on what's available to you. All the methods share the same initial step—write the code, then compile and link it for QNX Neutrino on the platform that you wish to run the program on.

Let's go through the steps necessary to build a simple QNX Neutrino program that displays the text "Hello, world!"—the classic first C program. The program itself is very simple:

#include <stdio.h>

main (void)
    printf ("Hello, world!\n");
    return (0);

You compile it for ARMv7 (little-endian) with the single line:

qcc -V gcc_ntoarmv7le hello.c -o hello

This executes the C compiler with a special cross-compilation flag, -V gcc_ntoarmv7le, that tells the compiler to use the gcc compiler, QNX Neutrino-specific includes, libraries, and options to create an ARMv7 (little-endian) executable using the GCC compiler. At this point, you should have an executable called hello.

To see a list of compilers and platforms supported, simply execute the command:

qcc -V