Project Home
Project Home
Discussion Forums
Project Information
Project Info
wiki3406: ProjectsBuildAndIDE (Version 19)

This page is under construction

Projects, Build and IDE#

This article will talk about how to set-up projects in QNX Momentics IDE, what types of projects to pick and how to organize projects to perform effective builds from IDE and command line. This article based on IDE 4.5.1 and some IDE 4.6 features.

What do you need to know about IDE project model#

Qnx Momentics IDE is based on open source Eclipse platform and open source CDT project which give essential part of functionality of projects and builds. IDE uses concept of "Workspace" which is user specific writable directory on the local host. This directory itself should never be part on revision control system shared between users nor be located on shared drive (unless you sure only one user using it). IDE (Eclipse) uses concept of "project" which is container for source and binaries together with some configuration files, which usually is located in workspace, which can be shared between users using version control system. Projects are flat - they cannot contain one another. However there is a concept of Working Set which allows you to filter and group projects if you have too many of them in a workspace. There is also special qnx Container project which allows you to control/build sets of projects at the same time.

When you pick location of workspace and names of the projects be aware that these names can be used in the build and make does not like directory/files with spaces and funky characters in them, even it is fine with IDE - build would not work with such paths.

If you used Visual Studio before you may think that project is virtual container which contains arbitrary files and directories - it is not the case with Eclipse. You can stretch eclipse project to use "Eclipse Links" but they have limited functionality. In general you have to have a directory in file system that contains project root (source and build output) and same directory would contain eclipse project metadata. If you want to separate project metadata from sources directories you have to use folder links. You have an option to put project inside workspace or outside workspace. You can use your imagination about how project directory is created - you can check out top level from one place, and subdirectories from another, you can use OS soft links or some other means to create it.

Qnx IDE supports 3 project types: Makefile project, Qnx project and Managed project.

Makefile Project#

Makefile project would work for any project that has a Makefile (by default). Technically it can launch anything as a external builder in any folder. IDE kicks make and after make exits IDE refreshes the workspace to see what you have created. You can change make command and/or run specific make targets, but IDE has no control over what make is doing.

Because IDE would not know what is building it would have problems parsing source files (which it does internally to allow Navigation, Code Completion, Syntax Highlighting, Code Generation and Refactoring). So if you using Makefile project you have to tune "Indexer" (the internal parser) to point it to where are missing Includes and what Defines your parser uses for conditional compilation. The process of figuring this out called "Discovery" and can be controlled using "Discovery Options". If you know what includes and defines you are using it is probably easier just to enter them directly (Project->Properties->C/C++ General -> Path and Settings).

Qnx Project#

Qnx project is special flavor or Makefile project with additional control over the make. To use qnx project you also have to use qnx recursive makefiles. Qnx recursive makefiles - are conventions for creating makefiles which uses specific variables and uses specific layout. This allow IDE to parse makefile and provide UI control over makefile options and build variants. Usually single qnx project is good to build one binary/library for several variants, such as x86 and pcc in debug, release and profiling modes.

Managed Project#

Managed project is CDT specific project which does not use makefiles, and all build settings are controlled by UI. The inconvenience of it is inability to perform a build of the project from command line* (* - although it is possible in simple cases with some extra setup files or you can use a makefile generator). Also there are restrictions on what you building and how, especially if you use special steps in the build which involves other tools.

Original Project Creation#

Lets consider scenarios when you creating project for the first time (in compare to checking out pre-made project, which will be discussed below)

When creating a new IDE project you have to pick from one of the following options:

  1. This is new project, I will create all sources in IDE
  2. The sources/structure exists already in the file system, I want to "attach" IDE project to it
  3. The project source/structure exists in the Version Control

New Project (#1) - pick one the project types described above. Use File->New... menu and pick C or C++ project wizard:

  • For Qnx Project pick "Qnx C Project" (or "Qnx C++ project" for c++). On the first page pick build variants. For example x86 Debug & Release.
  • For Makefile pick "C Project" (or "C++ Project" for c++). Select Makefile on the left. Pick QNX Toolchain on the right. Click Finish.
  • For Managed project pick "C Project" (or "C++ Project" for c++). Select one the projects types or templates on the left, except Makefile. Pick QNX Toolchain on the right. Click Finish.

Attaching to existing folder(#2) - pick one the project types described above for your project. Open corresponding wizard as described in #1, but don't proceed further. First wizard page would offer you to Use default location or pick one. Uncheck "Use default location". Select location of you existing project using "Browse" button. Follow the wizard as in #1. Alternatively you create project in default location but later attach other directory using link folders. See Example 4 below.

Checking out from source control(#3) - pick one of the project types described above for your project. If whole project is in one directory in version control you can use Check Out As... action of SVN or CVS plugins to check it out. Use "Check out as a project configured using New Project Wizard" and pick wizard of your choice. For Qnx project make sure you uncheck Generate default file and Generate Makefiles (? - not in 4.5 - need to revert to base to restore makefiles after check out). If you want a partial check out see next section.

Checking out partial source tree#

This procedure is how to create a project by checking out from several folders from version control system (example with SVN).

Lets say you have a folder in svn called big_project and it has 100 sub folders each of them represent different binary, but big_project has a makefile and some other common folders such as "public_includes" which you need to compile your subfolder "my_binary"

  • Follow instruction to check out a folder as new project (big_project) but de-select "Checkout recursively" (SVN cannot checkout one file; it has to be the whole folder).
  • Now find the "my_binary" subfolder in SVN, right click->Find/Check Out As.. and select "Check out as folder into existing project". Click Next.
  • Select previously created project. Click Finish.
  • If you need any other sub folders repeat the process.
  • Switch to C/C++ Perspective.

If you checked out more than one project that shares an SVN folder as its project root, you cannot commit the .project file back to SVN. You would need to add it to svn ignore to prevent showing up as changed resource.

Sharing projects#

Now when you have created a project you may want to "share" the settings so next person can just check it out as eclipse project. If given project root match with exactly one folder in source control system you may commit project metadata files back (.project and .cproject). If your project is attached to version control but you don't want them to be committed you have to add those file into "ignore" list.

Qnx project share most of options in makefiles itself, however some options such as current build variants are user specific (i.e. not in project metadata). You can make them "shared" by enabling "Share project properties" in the Main tab of Qnx project properties.

Checking out existing eclipse projects#

Source control IDE integrations (CVS and SVN) can detect presence of eclipse project metadata in the repository and check out pre-made projects. You have an option to search recursively and check out all exiting projects from selected folder or choose specific project. You can also create a special file called "Team Project Set" (.psf) which contains set of projects that you want everybody to check out. Team sets can be located in the source control repository as well and IDE will recognize them and should be able to check out all specified projects automatically.

Quick and Dirty project creation#

If you do not want to build using IDE but you suddenly want to use debugger, profiler or find memory corruption you can create a simple project in IDE to use by these tools. To do that:

  • Create empty Makefile project
  • Copy or Link sources into the project
    • To create a link - create a new directory in the project - in new directory dialog select Advanced and pick Link to folder
  • Copy or Link binaries and library into the project
  • Create launch configuration for selected tool
  • If you want source navigation and sources are not in the same location where they were compiled you need to enable Source Path Lookup - edit Source tab of launch configuration to provide a lookup

See more details in Example 4 below

Build Properties#

Qnx Project#

You can adjust build properties for qnx project using Project Properties or by modifying makefile. Be aware that If you modify makefile manually you can make it unrecognizable by IDE and it won't be able to properly update it in future,

Example of things you can do in Project Properties

  • Add extra libraries and library path (Linker tab -> Pick Extra Libraries from drop down)
  • Add extra includes (Compiler tab -> Pick Extra Include from drop down)
  • Define macro variables for whole project
  • Define macro and includes for one file (Click Advanced and pick file on the left)
  • Select more platform to build for (Build Variants tab)
  • Create another build variant (such as Profiling)
  • Change make variable (from Make Builder tab - override Build Command such as make DEBUG=1)
  • Add custom compiler and linker options
  • Change name of output binary/library

Managed Project#

You can adjust build properties for managed projects using Project Properties.

Example of things you can do in Project Properties

  • Add extra libraries and library paths (C/C++ Build->Settings->QCC Linker->Libraries)
  • Change output options such as add Debug, Optimize or Instrumentation options (C/C++ Build->Settings->QCC Compiler->Output Control). Some options require change in both compiler and linker.
  • Add custom linker or compiler options
  • Add another build variant (build configuration) (Manage Configuration... button in any page of C/C++ Build)
  • To set individual files option use same Properties but on the file/folder.

Other things:

  • To exclude file from a build - select a file and select Exclude from build from context menu
  • To include folder into the build it has to be "source folder". Or you click on folder select Properties and uncheck "Exclude from build" in C/C++ Build page.
  • You can Internal Build or External Make build with make generation. This is controlled from (C/C++ Build->Tool Chain Editor->Current Builder)

Makefile Project#

For makefile project you can change Location where build starts from and Make arguments (and command to launch make itself). Also you change Environment variables for the make invocation in Environment subcategory of C/C++ Build options. Same variable can be changed automatically from Settings tab, if you using qnx naming conventions for make variables. If they are defined in make itself env vars cannot override them, unless you use make -e.

All other options you set in your makefile.

Building from IDE#

To do simple build for active configuration select one or more project and select Build Project from context menu or from Project main menu. To clean project(s) select Clean Project.

For qnx and makefile project you can create and build specific make targets. Use context menu for that.

For managed project you can switch default active configuration and build using Build Configurations menu. You can also set global preference of whether to build one configuration or all when you do a Build on managed project (>= IDE 4.6).

For qnx projects if you want to build all project in specific configuration you can create Container project.

For managed project you can use Working Sets to build them together.

Setting up automated builds#

In IDE 4.5 to set up automated build you have to use make. If you are using managed project you have to use Gnu Make Build which would generate makefiles for you. If projects does not depend on anything you just run make in a root (or appropriate directory). If you want to build several project you have to create external makefile which references all subprojects. See details in IDEBuildFAQ.


Example 1

You local source (c++) files have the following structure:


You work in directory "mydir" yourself and just run make. Make picks up libraries from other pars of the file-system and picks includes from inc (and local ones inside mydir), To create project:

  • Select "New->C++ Project" (from context menu in Project Navigator)
  • Name "mydir" (or any name your like)
  • Uncheck "Use default project location"
  • Browse to pick directory "mydir" from file system
  • Select Makefile->Empty Project
  • Select QNX Toolchain
  • Click finish
  • Select new project and select Properties... from context menu (right click)
  • In Properties select C/C++ General->Paths and Symbols
  • Select GNU C++ and add Directory /source/a/inc as your include path (This required for internal parser - for code navigation, refactoring, syntax highlighting, etc)
  • Also if you know default macro that make used to build source add them here (For example if you compile as qcc -DDEBUG foo.c, add DEBUG macro)
  • Run Build Project

Alternative 2

Same as above but Makefile in the out directory, and this is build directory

  • Create project as above
  • Open Project Properties, click on C/C++ Build
  • As Build directory specify ${workspace_loc:/mydir/out}

Alternative 3

Same as first example but out directory is outside of mydir (Makefile in there still)

  • Create project as above
  • Select the project and select New->Folder from context menu
  • In folder dialog, click Advanced
  • Select Link the folder in the file system
  • Select output folder outside of project "mydir"
  • Click Finish

Example 4

Source code in directory A. Output binaries in directory B. Extra includes in directory C. All of them have common root D (for example D/x/y/z/A, D/x/C, D/w/C)

You want project itself with metadata somewhere else. You also want to share it if possible.


  • Create C++ Empty makefile project
  • In the project dialog use default project location (in workspace). Lets call it Project4. Click Finish.
  • Now we going to create link folders for A,B,C
    • In the project select New->Folder from context menu
      • Click Advanced, Check "Link the folder in the file system"
      • Select "Variables..." (If you don't have button, because of earlier version of IDE just select path from file system)
      • Add new variable called ROOT_DIR and select its path in file system pointing to directory D
      • In the dialog click Extend... and select subdirectory A
    • You should see path something like ROOT_DIR/x/y/z/A in the path. Click Finish
    • Repeat procedure for output directory B (you don't need to create ROOT_DIR again, just click Extend...)
    • Repeat procedure for extra include directory C (this is required so project setting can keep relative path, if you not going to share this project this step can be ommited)
  • Now you add extra include folder
    • In Properties select C/C++ General->Paths and Symbols. Select GNU C++ and add Directory C as include search path using "Workspace..." button (would look like /Project4/C).
  • Now let say make file in the folder A (source folder). We need to instruct IDE to run make from there.
    • Open Project Properties, click on C/C++ Build
    • As Build directory specify ${workspace_loc:/Project4/A}

Now Build Project, Clean Project should work. You should see your binaries in Binary container. And your includes in Includes container. Open a source and check that Include navigation works (Double click on external include in Outline view - you should navigate there).