Appendix: Tutorials

You can select a topic from this diagram:

Glossary What's New Utilities Used by the IDE Getting System Information Using Code Coverage Common Wizards Reference Preparing Your Target Developing Photon Applications Developing C/C++ Programs Where Files Are Stored Building OS and Flash Images Migrating to the 6.3 Release Tutorials IDE Concepts About This Guide Analyzing Your System With Kernel Tracing Profiling an Application Finding Memory Errors Debugging Programs Managing Source Code Launch Configurations Reference

Workflow diagram with tutorials chapter highlighted

Here are several tutorials to help you get going with the IDE.

In this chapter:

Before you start...

Before you begin the tutorials, we recommend that you first familiarize yourself with the IDE's components and interface by reading the IDE Concepts chapter.

You might also want to look at the core Eclipse basic tutorial on using the workbench in the Workbench User Guide (Help-->Help Contents-->Workbench User Guide, then Getting started-->Basic tutorial).

Tutorial 1: Creating a Standard Make C/C++ project

In this tutorial, you'll create a simple, Standard Make C/C++ project (i.e. a project that doesn't involve the QNX recursive Makefile structure).

You use the New Project wizard whenever you create a new project in the IDE. Follow these steps to create a simple "hello world" project:

  1. To open the New Project wizard, select File-->New-->Project... from the main menu of the workbench.
  2. Expand C (or C++) folder, and select Standard Make C (or C++) Project, then click Next:

    New Project Wizard

  3. Name your project (e.g. "MyFirstProject"), then click Finish. The IDE has now created a project structure.
  4. Now you'll create a Makefile for your project. In the Navigator view (or the C/C++ Projects view -- it doesn't matter which), highlight your project.
  5. Click the Create a File button on the toolbar:

    Create file button

  6. Name your file "Makefile" and click Finish. The editor should now open, ready for you to create your Makefile.

    Here's a sample Makefile you can use:

    all: hello
    hello: hello.c
        rm -f hello.o hello

    Note: Use Tab characters to indent commands inside of Makefile rules, not spaces.

  7. When you're finished editing, save your file (right-click, then select Save, or click the Save button in the tool bar).
  8. Finally, you'll create your "hello world" C (or C++) source file. Again, open a new file called hello.c, which might look something like this when you're done:
    #include <stdlib.h>
    #include <stdio.h>
    int main(int argc, char *argv[]) {
        printf("Hello, world!\n");
        return EXIT_SUCCESS;

Congratulations! You've just created your first Standard Make C/C++ project in the IDE.

For instructions on building your program, see the section "Building projects" in the Developing C/C++ Programs chapter.

Note: In order to run your program, you must first set up a Neutrino target system. For details, see:

Tutorial 2: Creating a QNX C/C++ project

Unlike Standard Make C/C++ projects, a QNX C/C++ project relies on the QNX recursive Makefile system to support multiple CPU targets. (For more on the QNX recursive Makefile system, see the Conventions for Makefiles and Directories chapter in the Neutrino Programmer's Guide.)

Follow these steps to create a simple QNX C (or C++) "hello world" project:

  1. In the C/C++ Development perspective, click the New QNX C Project (or New QNX C++ Project) button in the toolbar:

    New QNX C Project button

    The New Project wizard appears.

  2. Name your project, then select the type (e.g. Application).
  3. Click Next.
  4. In the Build Variants tab, check the build variant that matches your target type, such as X86 (Little Endian), PPC (Big Endian), etc. and the appropriate build version (release or debug).
  5. Click Finish. The IDE creates your QNX project and displays the source file in the editor.

Congratulations! You've just created your first QNX project.

For instructions on building your program, see the section "Building projects" in the Developing C/C++ Programs chapter.

Note: In order to run your program, you must first set up a Neutrino target system. For details, see:

Tutorial 3: Importing an existing project into the IDE

In this tutorial, you'll use the IDE's Import wizard, which lets you import existing projects, files, and even files from ZIP archives into your workspace.

Note: You can use various methods to import source into the IDE. For details, see the Managing Source Code chapter.

Follow these steps to bring one of your existing C or C++ projects into the IDE:

  1. Select File-->Import... to bring up the Import wizard.

    The Import wizard

  2. In the Import wizard, choose Other-->Existing Project into Workspace and click the Next button.

    The IDE displays the Import Project From Filesystem panel.

  3. Enter the full path to an existing project directory in the Project contents field, or click the Browse... button to select a project directory using the file selector.
  4. Click the Finish button to import the selected project into your workspace.

Congratulations! You've just imported one of your existing projects into the IDE.

Tutorial 4: Importing a QNX BSP into the IDE

QNX BSPs and other source packages are distributed as .zip archives. The IDE lets you import both kinds of packages into the IDE:

When you import: The IDE creates a:
QNX BSP source package System Builder project
QNX C/C++ source package C or C++ application or library project

For more information on System Builder projects, see the Building OS and Flash Images chapter.

Step 1: Use File-->Import...

You import a QNX source archive using the standard Eclipse import dialog:

Import BSP

As you can see, you can choose to import either a QNX BSP or a "source package." Although a BSP is, in fact, a package that contains source code, the two types are structured differently and generate different types of projects. If you try to import a BSP archive as a QNX Source Package, the IDE won't create a System Builder project.

Step 2: Select the package

After you choose the type of package you're importing, the wizard then presents you with a list of the packages found in $QNX_TARGET/usr/src/archives on your host:

Select BSP

Notice that as you highlight a package in the list, a description for that package is displayed.

To add more packages to the list:

  1. Click the Select Package... button.
  2. Select the .zip source archive you want to add.

Step 3: Select the source projects

Each source package contains several components (or projects, to use the IDE term). For the package you selected, the wizard then gives you a list of each source project contained in the archive:

Select projects

You can decide to import only certain parts of the source package; simply uncheck the entries you don't want (they're all selected by default). Again, as you highlight a component, you'll see its description in the bottom pane.

Step 4: Select a working set

The last page of the import wizard lets you name your source projects. You can specify:

Select working set

Note: If you plan to import a source BSP and a binary BSP into the IDE, remember to give each project a different name.

Step 5: Build

When you finish with the wizard, it creates all the projects and brings in the source from the archive. It then asks if you want to build all the projects you've just imported.

Note: If you answer Yes, the IDE begins the build process, which may take several minutes (depending on how much source you've imported).

If you decide not to build now, you can always do a Rebuild All from the main toolbar's Project menu at a later time.

If you didn't import all the components from a BSP package, you can bring in the rest of them by selecting the System Builder project and opening the import wizard (right-click the project, then select Import...). The IDE detects your selection and then extends the existing BSP (rather than making a new one).

QNX BSP perspective

When you import a QNX Board Support Package, the IDE opens the QNX BSP perspective. This perspective combines the minimum elements from both the C/C++ Development perspective and the QNX System Builder perspective:

BSP perspective

Congratulations! You've just imported a QNX BSP into the IDE.