unspoken reflections of my heart
Configure NS-2 with Eclipse in Linux
For most users of NS2, it would be easier if they can use a popular IDE to work with the files.
Here are the step by step instructions I followed to set up NS-2.34 with Eclipse 3.5 in Ubuntu Linux.
In older versions of Eclipse, the settings might be slightly different.
I have compiled the following steps after running into various problems and errors with the setup, and solving them all. So I hope the setup will be smooth for you.
Setting up Eclipse:
- Download Eclipse SDK
- Extract the SDK to a folder
- Open Eclipse
- Go to Help -> Install New Software. In the Work With bar type this:
http://download.eclipse.org/tools/cdt/releases/galileo - Choose CDT Main Features and CDT Optional Features. Install them.
CDT stands for “C/C++ Development Tooling” - If you do not have a working internet connection in the system you have installed Eclipse, instead of steps 4 and 5, download the CDT from the above mentioned site. Then move to Install New Software (see step 4) -> Add and add the archive downloaded.
Installing NS-2
- Download NS-2
- Extract NS-2 to a folder, i.e. /home/username/ns-allinone-2.34
- Edit Makefile:
- Open “…/ns-allinone-2.34/ns-2.34/Makefile.in”and
- Add these lines anywhere near the top of the file:
CCOPT = -g
DEFINE = -DNDEBUG
DEFINE = -DDEBUG - Navigate to …/ns-allinone-2.34/ns-2.34 and run “./configure”
- Navigate to the NS-2 folder using terminal and type ./install
- Also, follow the instructions are displayed at the end of a successful installation. These instructions are to modify the PATH variable and other environment variables as needed.
Adding NS-2 as a Project in Eclipse
- Open Eclipse
- Set the workspace as the ns installation path( /home/username/ns-allinone-2.34 ) by selecting File -> Switch Workspace
- Choose File -> New -> Project -> C++ Project
- Select Project Type as Makefile Project -> Empty C++ Project.
Toolchains: Linux GCC - Enter Project Name as ns-2.34
- Uncheck “Use default location” then browse to the directory NS-2 source directory ( …/ns-allione-2.34/ns-2.34 )
- Select “Next” and “Finish.
- From the workspace, Selecting the NS-2 Project and choosing Project -> Build All should not give Error.
- Running the project must open the console with the NS-2 prompt, %
Setting Debug Configuration:
- Select Run -> Debug Configurations
- Choose C/C++ Application. Type in any name.
- Under the Main tab, Choose the following:
Project as ns-2.34.
C/C++ Application as ns. (Search Project and Choose this) - Under the Debugger tab, choose GDB Debugger. Uncheck the “Stop on startup at” option.
- Apply and Debug.
Update from Readers: Changes to be made in Makefile.in file:
Add -g to the line CCOPT = @V_CCOPT@
CCOPT = @V_CCOPT@ -g
Add -DNDEBUG -DDEBUG to the end of the following line:
DEFINE = -DTCP_DELAY_BIND_ALL -DNO_TK @V_DEFINE@ @V_DEFINES@ @DEFS@-DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=@CPP_NAMESPACE@-DUSE_SINGLE_ADDRESS_SPACE -Drng_test -DNDEBUG -DDEBUG
Special thanks to Ella Taha for notifying me about the correction!
You might also like:| Print article | This entry was posted by eskay on October 18, 2009 at 11:44 pm, and is filed under linux, technology. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |




about 1 year ago
Hi,
I have tried to follow your procedure in your blog to compile ns2 using eclipse galileo. I am frustrated because I did not find the “normal” eclipse, where everything was fine. Do you know if it is possible to use that instead of eclipse galileo?
Related to eclipse galileo, I can not see the options you described in the IDE:
“Select Project Type as Makefile Project -> Empty C++ Project.
Toolchains: Linux GCC”.
My eclipse galileo version Version: 3.5.2 Build id: M20100211-1343.
Could you help me?
about 1 year ago
Thanks, I tried it with helios and it worked fine.
about 11 months ago
I read your blog “Configure NS-2 with Eclipse in Linux” and have tried to follow your procedure,but I have a problem that when I come to “browse to the directory NS-2 source directory ( …/ns-allione-2.34/ns-2.34 )”,the eclipse has a error that /home/lynn/ns/ns-allinone-2.34/ns-2.34 overlaps the location of another project: ‘ns-2.34′ .
My eclipse galileo version Version:3.5.2
Could you help me?
about 11 months ago
I guess you are trying to create two projects in the same location using Eclipse.
This is not permitted.
Check out Help in Eclipse. Also, Google can provide you help on this
Cheers!
about 10 months ago
Hi. I followed the steps and it works perfect. But my problem is what do I do now, because I have to run a tcl file. I Sourced the file in the ns terminal but the break points are not hit.
Hope you can provide some help.
about 8 months ago
Hi,
I followed all configuration steps but when i want to build ns-2.34 project , i get two following errors :
ISO C++ forbids declaration of ‘init_misc’ with no type ns_tclsh.cc /ns-2.34 line 30 C/C++ Problem
make: *** [ns_tclsh.o] Error 1 ns-2.34 line 0 C/C++ Problem
Hope you can provide some help.Thank you
about 7 months ago
Hi
I followed all the steps written here in eclipse hellios, it builds and runs my tcl file with no errors . However, it doesn’t stop at the breakpoints when debugging, and debug returns the exact same thing as run.
I would really appreciate any help!
about 7 months ago
Hi,
I am sorry I am unable to help. I have been completely out of touch with ns2. It has been over two years since I worked on it, so am not sure how to help.
Currently I am completely into J2EE programming.
Apologies.
Karthik
about 7 months ago
Thank you, Ella, for notifying me about the changes required to get it working!!
about 7 months ago
Ok so here is what I did to make the debug work:
I changed the Makefile.in in the ns-2x subdirectory as the following:
1. change CCOPT = @V_CCOPT@
to CCOPT = @V_CCOPT@ -g
2. add -DDEBUG -DNDEBUG to the end of the DEFINE parameter such as:
DEFINE = -DTCP_DELAY_BIND_ALL -DNO_TK @V_DEFINE@ @V_DEFINES@ @DEFS@ -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=@CPP_NAMESPACE@ -DUSE_SINGLE_ADDRESS_SPACE -Drng_test -DDEBUG -DNDEBUG
now run “./configure” and then “make clean” and “make” in the same directory. After that go hit the debug button in the eclipse and enjoy what you see!
about 7 months ago
Hi Ella,
I tried the two extra changes you suggested. Strange! I am getting many errors while running the make command which are mostly related to declaring the variable types. Did you get those errors too?
What will the changes you suggested do?
Thanks for the help.
about 5 months ago
please refer these sites for ns2
http://www.pradeepkumar.org
http://www.nsnam.com
about 5 months ago
I had similar issues, it was because of instead of creating a Makefile project I was creating a Project (Default option). See point 4 below
4. Select Project Type as “Makefile” Project -> Empty C++ Project.
Toolchains: Linux GCC
about 5 months ago
Hi,
I did as suggested by you. I am confused do i need to put in breakpoints in files myself. I am not sure in which files to place the breakpoints.
Additionaly, is there any way i can debug my simulation written in tcl.
Thanks
about 3 months ago
very nice written, I spent days to make it work on my SUSE until I looked at your post.
Thank you.
about 2 months ago
Thanks, I tried it with indigo and it worked fine. But, I tried with Ella way, and I got many error. Are these normal?
I have successed configure eclipse and ns2, but I still don’t understand how to debug with eclipse. I hope you will write articles about it later. Sorry for my english
about 1 month ago
You should pass your tcl file as argument to ns.
Go to debug configurations and under arguments tab, write the name of your .tcl file. With its path of course.