How to develop and test code with netbeans.

Building Cloudy with Netbeans

  • To start do file / new project / "c/c++" / "c/c++ project with existing sources" - click next
  • Select mode screen We tell it how to find the source by filling in the "specify the folder that contains existing sources" window. Click the Browse... button to the right. Browse down to source and select it. In "select configuration mode" choose "Custom" - click next
  • Build tool screen - select "using an existing makefile" then browse down to, and select, Makefile in source/sys_gcc. You can use the Makefile in source if you only want one type of build. By using the Makefile in one of the sys_XXX folders you can have several different types of builds. Select "clean and build after finish" - click next
  • Build actions screen. Select "Browse" option for "Working Directory" and make sure it points to the sys_gcc directory. Add parameters to "Build command". You can build in less time by adding the parameter "-j X" where X is the number of threads it can use. The "build result" is now incorrect but will be fixed at a later stage - click next
  • Source Files screen - select "Add Folder" button to add "source" directory - click next
  • Code assistance configuration screen - select "Automatic Configuration" - click next
  • Project name and location screen - enter name for project in "Project Name" - do not accept name that netbeans proposes - clear or set flag "Set as Main Project" - click finish

The code will build at this point.

To run, click the green arrow (more of a green triangle standing on end) in the top set of icons. Netbeans will not be able to find the executable the first time you try this. In the window that appears browse down to "cloudy.exe" in source/sys_gcc. You must set the "file format" option to "All Files".

Setting project parameters

Right click project name / properties in list of projects window on the left.

Create a debug (and other) configurations

The executable created above will be highly optimized. As a result it may be difficult to work with the source in the netbeans debugger. You should create a debug build with low optimization so that all local variables actually exist. Do the following to create a debug build to the project we just created

  • Right click the project name in the list of projects in the left window. Select properties then the "Manage Configurations ..." button on the top right. You may wish to change the name of the default configuration created above to "optimized". Click "new" and specify a name. In each option window you will have access to all configurations to specify parameters for each.
  • To make a debug configuration add "debug" to the project properties / build / make command. It will appear something like ${MAKE} debug -f Makefile -j 4
  • file / project properties / build / make - mistake on "build result" window - should have been ./cloudy.exe

Trapping asserts in the Netbeans interactive debugger

  • Setting breakpoints in netbeans Click on the vertical gray bar to the left of the source. The breakpoint will appear as a pink square.
  • Set the breakpoint for trapping asserts Place a breakpoint in the function bad_assert::bad_assert()) in the file cddefines.cpp. The code will pause there if an assert is thrown.
  • Start the ide debugger click the green right arrow on top of code icon.
  • Enter the commands Enter commands for the model in the window that appears.

Setting macros

set with EXTRA option on make command.

Converting realnum to double A specific example - project / properties / build / make / build command / set to ${MAKE} -f Makefile -j 2 EXTRA="-DFLT_IS_DBL"

Pasting input script into the debug window

When you start the debugger an xterm window will appear. Type or paste the input stream into this window to start debugging. For instance, to run the smoke test enter test followed by a few carriage returns. To enter more complex input scripts copy the input into the buffer. You do this with the command pbcopy < on a Mac. Paste this into the xterm windows.

To do an xterm paste on a Mac first open an xterm window, go to X11/Preferences on the menu bar, select "Emulate three-button mouse." Then paste with option-click.

Tabs and the Netbeans editor

By default the editor will create indentation with spaces. The Cloudy style is to use tabs. You must set up the editor to use tabs. Go to Netbeans / preferences / editor / formatting

The language dropdown has the following options, all of which must be reset: all languages, C, C++, C/C++ header

In each clear the "expand tabs to spaces" option under the "formatting style" category.

Return to DeveloperPages

Return to main wiki page

Last modified 23 months ago Last modified on 2018-12-05T14:52:50Z