Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/ide_en/user_guide/tutorials.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/ide_en/user_guide/tutorials.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/ide_en/user_guide/tutorials.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/ide_en/user_guide/tutorials.html on line 8

Appendix: Tutorials

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 and Getting Started chapters.

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 C/C++ project


Note: In earlier versions of the IDE, there were two different project types: Managed make, which automatically generated a makefile, and Standard make, which required a makefile to build. Now, you are required to select a project type, and that determines the build system to use.

In this tutorial, you'll create a simple, 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 the C (or C++) folder, and select C (or C++) Project.

    New Project Wizard: Select a project type

  3. Click Next.
  4. Name your project (e.g. MyFirstProject).
  5. In the Project type list, expand Makefile Project and select Empty Project.

    New Project Wizard: Select a project type

  6. Select a required toolchain from the Toolchain list.

    A toolchain represents the specific tools (such as a compiler, linker, and assembler) used to build your project. Additional tools, such as a debugger, can also be associated with a toolchain. Depending on the compilers installed on your system, there might be several toolchains available to select from.

  7. Click Next.

    New Project Wizard: select configurations

  8. Optional: Click Advanced settings to edit the project's properties.

    The fields for each panel are described in the “Project options” section, in the Wizards chapter.

  9. Expand C/C++ Build and select Settings.
  10. Click the Binary Parsers tab.
  11. Select a parser.

    To ensure the accuracy of the Project Explorer view and the ability to successfully run and debug your programs, it is important to select the correct parser. After you select the correct parser for your development environment and build your project, you can view the components of the .o file in the Project Explorer view. You can also view the contents of the .o file in the C/C++ editor.

  12. Click OK.
  13. Click Finish.

    The IDE creates your new project in your workspace. Your new project shows in the Project Explorer view, and in the Navigator view. If a message box prompts you to change perspectives, click Yes.

    C/C++ Perspective

    Now you'll create a Makefile for your project.

  14. In the Project Explorer view, highlight your project.
  15. Click the Create a File button on the toolbar:

    Create file button

  16. 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:

    CC:=qcc
    
    all: hello
    
    hello: hello.c
    
    clean:
        rm -f hello.o hello

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

  17. When you're finished editing, save your file (right-click, then select Save, or click the Save button in the tool bar).
  18. 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 Make C/C++ project in the IDE.

For instructions about 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 C/C++ projects, a QNX C/C++ project relies on the QNX recursive Makefile system to support multiple CPU targets. (For more information about the QNX recursive Makefile system, see the Conventions for Recursive 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, select File-->New-->Project… from the main menu of the workbench.
  2. Expand the C (or C++) folder, and select QNX C Project (or QNX C++ Project), then click Next.

    The New Project wizard appears.

  3. Name your project, then select the type (e.g. Application).

    Note: Even though the wizard allows it, don't use any of the following characters in your project name (they'll cause problems later): | ! $ ( " ) & ` : ; \ ' * ? [ ] # ~ = % < > { }

    New QNX C Project: Project name and type

  4. Click Next.
  5. On the Build Variants tab, expand the build variant that matches your target type, such as X86 (Little Endian), PPC (Big Endian), etc., and then select the appropriate build version (release or debug).

    New QNX C Project: Build Variants tab

  6. Click Finish.

    The IDE creates your QNX project and shows the source file in the editor.

    New QNX C Project: Build Variants tab

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

For instructions about 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, as well as 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 open the Import wizard.
  2. In the Import wizard, select General-->Existing Projects into Workspace.

    The Import wizard

  3. Click Next.

    The IDE shows the Import Project From Filesystem panel.

  4. Do one of the following:
  5. In the Projects list, select the projects that you want to import from the location you specified.

    Use the following buttons to help you make your selections:

  6. Optional: Select the Copy projects into workspace option to cause the imported project to be copied into the current workspace.
  7. Click Finish 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 source package and BSP 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.

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


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/ide_en/user_guide/tutorials.html on line 356

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/ide_en/user_guide/tutorials.html on line 356