Howto Use OpenFOAM with NetBeans

From OpenFOAMWiki

NetBeans is a free, open-source Integrated Development Environment that runs on several platforms including Windows, Linux, Solaris, and MacOS. It is easy to install and use straight out of the box.

The C/C++ development pack (available as a separate download) adds project types for C and C++ NetBeans Projects and includes appropriate C/C++ templates. NetBeans supports C/C++ applications with dynamic and static libraries, and projects with existing code. It also includes an advanced source-code editor which features code-completion, smart-indenting and syntax-highlighting capabilities. It readily integrates with an existing compiler installation (like gcc), and provides an interactive debugging environment (using gdb as a backend).

Screenshot

1 Configuring scripts

NetBeans uses gmake during the compilation process. To configure NetBeans for use with wmake, a few changes to the wmake script will be necessary. For a quick and easy solution, make a copy of the wmake script (located in $WM_PROJECT_DIR/wmake) in the same directory, and give it a new name (like nbmake, for instance). Edit the file, comment out the section between:

 
#------------------------------------------------------------------------------
# check arguments and change to the directory in which to run wmake
#------------------------------------------------------------------------------
.
.
.
#------------------------------------------------------------------------------
# Check the existance of the Make directory and files file
# If both exist make the wmake derived files
#------------------------------------------------------------------------------

and add these lines:

 
curDir=`pwd`
 
makeOption=""
dir="_"
MakeDir=Make
 
# Check for Debug/Release
if [ $# = 3 ]
then
    if [ $3 = "CONF=Debug" ]
    then
	export WM_COMPILE_OPTION=Debug
    fi
    if [ $3 = "CONF=Release" ]
    then
	export WM_COMPILE_OPTION=Opt
    fi
fi
 
# Check if clean-up was requested... If so, call wclean
if [ $# = 4 ]
then
    if [ $4 = "clean" ]
    then
	echo $0: Clean requested...
	wclean
	exit 0
    fi
fi

Example scripts for OF-1.3 and OF-1.4.1 are available here. Depending on the install configuration, your mileage may vary.

2 Setting up NetBeans for use

Start NetBeans and make the following changes under the Build Tools tab in Tools->Options->C/C++

Change the Make Command to the new script (eg. nbmake) Ensure that the Gdb Command, C and C++ compiler point to the correct installations on your system.

In the Code Assistance tab, under C++ Compiler, add all the lnInclude directories that you need from the /src directory of your OpenFOAM install. This will add code-completion capabilities.

Create a New Project under the File menu, select C/C++ under Categories, and C/C++ Application under Projects. In the following menu, provide a directory name for Project Name and Project Location. Leave the Project Makefile Name as it is (this is never used anyway). Click Finish.

Add any existing source/header files using the panel on the left. Right-click the project on this panel and select Properties. Under the General option in Linker, change the Output field to an appropriate directory for the output binaries.

Clicking Build Main Project should now call the nbmake script.

3 Download

NetBeans is available here.

The C/C++ Development Pack is available here.