Howto Use OpenFOAM with NetBeans

From OpenFOAMWiki
Revision as of 19:08, 1 March 2014 by Wyldckat (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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).


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:

# Check for Debug/Release
if [ $# = 3 ]
    if [ $3 = "CONF=Debug" ]
    if [ $3 = "CONF=Release" ]
# Check if clean-up was requested... If so, call wclean
if [ $# = 4 ]
    if [ $4 = "clean" ]
	echo $0: Clean requested...
	exit 0

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.