Difference between revisions of "HOWTO configure NetBeans with ns-3"

From Nsnam
Jump to: navigation, search
(Initial short version)
 
(Make the guide more detailed)
Line 1: Line 1:
Short version, taken from [https://groups.google.com/forum/?fromgroups=#!msg/ns-3-users/sk6HsRiNp4U/5V0FTCt7z3UJ ns-3-users group post].
+
== Basic Configuration ==
 +
Idea taken from [https://groups.google.com/forum/?fromgroups=#!msg/ns-3-users/sk6HsRiNp4U/5V0FTCt7z3UJ ns-3-users group post].
  
* Insert the Makefile-wrapper for waf into the project-root ( http://ftp.samba.org/pub/unpacked/tdb/buildtools/scripts/Makefile.waf).
+
=== Makefile wrapper ===
* Edit it till it's working;) ( you have to use the Makefile, because netbeans needs it to recognize it as a project)
+
NetBeans needs a Makefile to recognize a project as such. Create a file named '''Makefile''' inside ns-3-dev directory, containing the following.
* NetBeans: New Project -> C++ Project With Existing Sources -> Choose the root-folder (something like ns-3-dev)
+
 
* Waf clean/build will be executed, this may take some time.
+
# Makefile wrapper for waf
* Edit Project properties -> Run config -> disable "Build first".  
+
* Edit "Run command" to "./waf --run my-example". (Of course, don't use "my-example".)
+
all:
 +
    ./waf
 +
 +
configure:
 +
# free free to change this part to suit your requirements
 +
./waf configure --enable-examples --enable-tests
 +
 +
build:
 +
      ./waf build
 +
 +
install:
 +
        ./waf install
 +
 +
clean:
 +
      ./waf clean
 +
 +
distclean:
 +
./waf distclean
 +
 
 +
=== Importing project ===
 +
* Run "./waf shell", and then '''in the same terminal''' start NetBeans using "netbeans" command.
 +
** Inside NetBeans go to ''File->New Project...'', choose ''C/C++->C++ Project with Existing Sources'', and click ''Next >''.
 +
** Choose '''ns-3-dev''' under ''Specify the folder that contains existing sources:'' and make sure that ''Auotomatic (using Makefile)'' is selected under ''Select Configuration Mode:''. Click ''Finish''.
 +
** Waf clean and build get executed by NetBeans, this may take some time.
 +
 
 +
=== Editing project properties ===
 +
* Right click on ''ns-3-dev'' in ''Projects'' and select ''Properties''.
 +
** Under ''Run'', Set ''Run Command'' to "./build/examples/tutorial/ns3-dev-first-debug" or any executable you want to run and debug.
 +
*** If you want to set it to "/build/examples/tutorial/ns3-dev-first-debug" make sure you used "--enable-examples" option in "./waf configure" under Makefile.
 +
 
 +
== Running programs ===
 +
* Click ''Run Project (ns-3-dev)'' button.
 +
 
 +
== Debugging programs ==
 +
* Set breakpoints and click ''Debug Project (ns-3-dev)'' button.
 +
* To debug a running ns-3 program, use ''Attach Debugger...'' under ''Debug'' menu or ''Debug Project (ns-3-dev)'' button dropdown.
 +
 
 +
== FAQ ==
 +
* Q: Code Assistance doesn't work in a particular file.
 +
** A: Doing the following two things usually solves this.
 +
*** Right click on ''ns-3-dev'' in ''Projects'' and select ''Code Assistance->Reparse Project''.
 +
*** Change something in that particular file, save it and use ''Build Project (ns-3-dev)'' button or ''Run Project (ns-3-dev)'' button.

Revision as of 13:14, 2 January 2013

Basic Configuration

Idea taken from ns-3-users group post.

Makefile wrapper

NetBeans needs a Makefile to recognize a project as such. Create a file named Makefile inside ns-3-dev directory, containing the following.

# Makefile wrapper for waf

all:
    	./waf

configure:
	# free free to change this part to suit your requirements
	./waf configure --enable-examples --enable-tests

build:
      	./waf build

install:
       ./waf install

clean:
      	./waf clean

distclean:
	./waf distclean

Importing project

  • Run "./waf shell", and then in the same terminal start NetBeans using "netbeans" command.
    • Inside NetBeans go to File->New Project..., choose C/C++->C++ Project with Existing Sources, and click Next >.
    • Choose ns-3-dev under Specify the folder that contains existing sources: and make sure that Auotomatic (using Makefile) is selected under Select Configuration Mode:. Click Finish.
    • Waf clean and build get executed by NetBeans, this may take some time.

Editing project properties

  • Right click on ns-3-dev in Projects and select Properties.
    • Under Run, Set Run Command to "./build/examples/tutorial/ns3-dev-first-debug" or any executable you want to run and debug.
      • If you want to set it to "/build/examples/tutorial/ns3-dev-first-debug" make sure you used "--enable-examples" option in "./waf configure" under Makefile.

Running programs =

  • Click Run Project (ns-3-dev) button.

Debugging programs

  • Set breakpoints and click Debug Project (ns-3-dev) button.
  • To debug a running ns-3 program, use Attach Debugger... under Debug menu or Debug Project (ns-3-dev) button dropdown.

FAQ

  • Q: Code Assistance doesn't work in a particular file.
    • A: Doing the following two things usually solves this.
      • Right click on ns-3-dev in Projects and select Code Assistance->Reparse Project.
      • Change something in that particular file, save it and use Build Project (ns-3-dev) button or Run Project (ns-3-dev) button.