[TUTORIAL] How to configure a Waf C++ project in Eclipse [UBUNTU 14.04]

1,915 views
Skip to first unread message

Vaison

unread,
Jan 25, 2015, 2:27:08 PM1/25/15
to ns-3-...@googlegroups.com
I don't know if the admins would consider a "repetitive" contribution for the forum this tutorial, but I've got some troubles with eclipse and NS-3 and I would like to help others users.

First of all, you have to download Eclipse IDE for C/C++ Developers (https://eclipse.org/downloads/packages/eclipse-ide-cc-developers/keplersr2)

Then you have to download NS-3 (my case 3.21) https://www.nsnam.org/release/ns-allinone-3.21.tar.bz2

After that, you have to open eclipse and Create a New C++ Project
Select File -> New -> C++ Project
http://s13.postimg.org/bhk8idhjn/1ok.jpg
http://s13.postimg.org/dan56p2qb/2ok.jpg

Now we have to import ns-3 folder so right-click to the project and select:
Import -> General -> File System
http://s13.postimg.org/jpm63d9g3/3ok.jpg

We have to configure the build toolchain to use waf instead the default make. Right-click to the project and select:
Properties -> C/C++ Build

In the tab Builder Settings you have uncheck all the options checked and set the Build Command field to your waf path. In my case:
${workspace_loc:/ns3test/ns-3.21}/waf

And for the build directory my path is:
${workspace_loc:/ns3test/ns-3.21}/waf

http://s13.postimg.org/jjd2e0poz/5ok.jpg

Then go to Behaviour tab and set build and clean respectively as below

http://s13.postimg.org/3wlt0nbwz/6ok.jpg

For enable the configure options in waf we should to follow the next steps:
Right-click to the project and select:
Make Targets -> Create ...
Select a name and fill the rest of the fields, there are different combinations for these example I've used:
Make Target field
configure --enable-examples --enable-tests

Build command field:
/home/alumni/workspace/ns3test/ns-3.21/waf

http://s13.postimg.org/by5g4t5ar/7ok.jpg

To run your compiled project:
Right-click to the project and select:
Run AS -> Run Configuration...
Select C/C++ Application and New launch configuration
http://s13.postimg.org/3txc02ivn/8ok.jpg

Just have to select a Name
In the field project click on Browse and select ns3 in that case ns3 test
ns3test

And then in C/C++ Application click on Search Project and select your file, in that case I called test
ns-3.21/build/scratch/test

http://s13.postimg.org/8tus80oib/9ok.jpg

Most probably after click run is that you get a library error like this:
error while loading shared libraries: libns3.21-lr-wpan-debug.so: cannot open shared object file: No such file or directory

As Yeison Camargo sais in his thread (https://groups.google.com/forum/#!topic/ns-3-users/EMnZk1UpLQY) we have to create a symbolic link, I advise create a symbolic link for all libraries:
sudo ln -s /home/alumni/workspace/ns3test/ns-3.21/build/libns3.21-* /usr/lib/

Then you can run and debug without problems

I hope it is be useful for someone.

Regards,

~V

PD: some steps taken from http://anhnguyen.me/2014/07/how-to-configure-a-waf-cxx-project-in-eclipse/

Konstantinos

unread,
Jan 25, 2015, 3:48:40 PM1/25/15
to ns-3-...@googlegroups.com
Hi Vaison,

There is a HOW_TO in the NS-3 wiki page on this matter
https://www.nsnam.org/wiki/HOWTO_configure_Eclipse_with_ns-3

Could you check if there is any change/difference/update from this and your post and propose any extentension it if needed.

Johnathan Joestar

unread,
Feb 4, 2015, 4:20:34 PM2/4/15
to ns-3-...@googlegroups.com
i agree, you should update the wiki, i think you will help a lot of people making NS3 more accesible

pragendra sahu

unread,
Aug 19, 2015, 8:31:29 AM8/19/15
to ns-3-users
Hi,

Your Instructions are really helpful.I searched too much, finally this post helped me.
 
Thanks,
Pragendra

Reply all
Reply to author
Forward
0 new messages