Developing Existing Application
With the NetBeans C/C++ Development Pack

The following short tutorial takes you through basic steps of developing your existing C/C++ application using the NetBeans™ C/C++ Development Pack.

The sequence of these steps is not "ideal"; this is done intentionally. We will face some typical problems and solve them; we would not face this problems if all information we entered was absolutely correct and complete. But we are not in an ideal world. So we will go the most typical way instead.

We will use Squirrel Shell project as an example. Squirrel Shell is an open source project taken from Internet: Squirrel Shell is made as a cross-platform alternative to system shells like bash in Linux and in MS Windows. It is based on the scripting language named "Squirrel".

Configuring project

Go to project page (, download archive with sources and extract them into some directory.

The Squirrel Shell is an autoconf project. For now there is no autoconf support in NetBeans™ C/C++ Development Pack. You have to configure the project manually. Launch cygwin shell, change directory to the one you extracted project into and run ./configure.

Creating a project

You can create a project using a wizard. If you know every minute detail concerning your project, and understand, which of these details are important for IDE to work properly, then your project is completely ready after you finish the wizard.

In most situations though, you use default values for many fields, and correct these values via project properties dialog later on, when you encounter a problem. Our Squirrel Shell example is the case.

  1. Open the New Project wizard by choosing File > New Project.

  2. Select the C/C++ Development category.

  3. Select C/C++ Project From Existing Code and click Next. You will see the following wizard page.

    Fill the "Existing Makefile" field: press "Browse" button, find Squirrel project location, and select Makefile. After that other fields (except for "Build result") are automatically filled with default values.

    You can fill "Build Result" field if you know what binary is produced by the project or you may postpone this and leave the field empty. Since we do not know what particular file will Squirrel Shell produce, we leave this field empty and click next.

  4. Add source files to project.

    To make your project, IDE needs only makefile, working directory and target. Nevertheless, code assistance features (code completion, hyperlink navigation, class view, etc.) needs to know more. They needs to know the exact list of the project files. They also need to know include search paths and macros.

    The wizard scans project directories for source files and adds files that are found to projects. You can specify several directories. You can also specify file types to search for (headers, sources or both). By default, your project working directory is searched for.

    Note that you can also add files to your project later on, via "Add Existing From Folders" item in Project Explorer context menu

    You can also specify two fields that are used by built-in parser: include directories (corresponds to -I compiler option) and macros (corresponds to -D compiler option). You can also specify both later on.

  5. Enter project name and location. Here you enter the name and location of NetBeans™ C/C++ Development Pack project that contains all necessary infrastructure.

    By default this project is placed in a separate directory, not in the directory your makefile and sources reside. (Note that a trailing "1" is added to your initial project directory). You can make these directories the same; but this can cause name conflicts and version control system problems.

    Press Finish.

Building project. Take one.

Press F11 key (or select Build > Build Main Project main menu item; or press correspondent toolbar button)

See the following messages in output pane

    Specify one of these targets:

This mean our makefile does not have default target, so we should specify one explicitly

Entering correct make target.

Let's assume we are on 32-bit x86 machine.

Go to the project properties (either via "File" > "Squirrelsh-1.01 Properties" or via "Properties" item on the project explorer context menu). Select "Make" node in propertied tree:

Append x86-debug to "Build Command" field.

We'd surely like to be able to build release version either; we'll describe how to add configurations in the end of this article: now our main goal is to make the project build at least for one configuration.

Building project. Take two. Running project.

This time it builds perfectly.

Try running the project. To do this you can select Run > Run Main Project or press F6 key or use toolbar button.

It shows "No executable specified in the project". Let's go to the project properties, select "Make" in the properties tree and fill "Build Result" field. In our case it's ../squirrelsh-1.0/bin/squirrelsh.exe (The path is relative to the project infrastructure directory).

We might fill this field in project creation wizard if we knew the exact name and location of the binary. On the other hand it's more convenient to do this now since the project is already built, so now we can just select binary from the list (press "..." button to the right of "Build Result" field).

Correcting information necessary for code assistance

At this moment you may see some indications that IDE needs some more information about your project.

The first indication is an error sign in the lower-right corner of the IDE window:

Another indication is that in some files (for example, common.h) #include directives are underlined red:

What does this mean, you wonder - the project is built successfully?!

This concerns built-in parser and thus code assistance functionality (completion, hyperlink, etc.). This does not concern build. This would not happen if you use managed project (Application, Dynamic or Static Library). Usually managed projects are used for creating project from scratch. For such projects, all necessary information is stored in project infrastructure; makefile is just generated.

Since we are working with existent, i.e. makefile-based project, only makefile contains such important compiler options as -I and -D. Built-in parser that is used for code assistance knows nothing about these options.

For this release, the problem of extracting these options from makefile is not solved. So you have to tell IDE correct values for these options in order to make code assistance (code completion, hyperlink navigation, class view, etc.) work properly.

Double-click error sign in the lower-right corner of IDE window. You will see the following dialog

The list on the right contains all #include directives that failed to resolve.

If you select one, right list shows all files that contains this #include directive.

Here we see that parser can not find squirrel.h file on the include paths. We can go to project explorer and understand that it is in "include" subdirectory. Add this directory to the include search path list:

Open project properties; select Parser Configuration > GNU C++ Compiler. Add ../squirrelsh-1.0/include to "Include Directories" field.

Note that this field content is relative to project infrastructure directory

Unfortunately, version 1.0 of the NetBeans™ C/C++ Development Pack has a problem: it's built-in parser does not reparse the project after it's options are changed. So you have to either close and reopen project to put these options into effect or just switch code assistance off and back on for this project. You can do this via "Code Assistance" checkbox menu item in Project Explorer context menu.

Adding configurations.

We added only x86-debug target. Now since our project works ok, we'd like to be able to build both debug and release versions.

Go to project propertied and press "Manage Configurations" button.

Rename "Default (active)" configuration to the "Debug". Then press "Copy" button. It will create "Copy_of_Debug" configuration. Rename it to "Release" and press OK.

Note that "Configuration" drop-down box at the top of Project Properties dialog now contains three items:

  • Debug
  • Release
  • <All Configurations>

Select "Release" and change x86-debug to x86-release. Press OK.

Note that you can easily switch configurations via drop-down box that resides in the main toolbar. Try rebuilding both Debug and Release; note the difference in compiler options.

Project Features

About this Project

CND was started in November 2009, is owned by DimaZh, and has 233 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20160708.bf2ac18). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
Please Confirm