NS-3 and Eclipse

616 views
Skip to first unread message

Di

unread,
Aug 4, 2009, 4:26:10 PM8/4/09
to ns-3-users
I want to be able to build and run NS-3 through eclipse, and I was
wondering if anyone has done it.

Thanks.

cb

unread,
Aug 4, 2009, 11:36:40 PM8/4/09
to ns-3-users
I've not tried that yet, but if you stick to C++ you'll just have to
set the relevant paths for the ns3 library (either debug or optimized
version) and headers. for running the program, remember to set
LD_LIBRARY_PATH if you're in linux, or place the ns3 library you want
to use in a system-known location if you're on windows.

Faker Moatamri

unread,
Aug 5, 2009, 4:26:11 AM8/5/09
to ns-3-...@googlegroups.com
I use eclipse with ns-3 and I'm pretty happy with it. Here are 2 screen
shots of the builder configuration.
You can install the mercurial plugin and create a new empty C++ project
with eclipse then download it manually to the target directory using hg
clone http://code.nsnam.org/ns-3-dev targetDir, then on eclipse you
click right on the project and go to team, share project and you use the
local directory mercurial configuration. This should be enough to make
eclipse manage Mercurial.
I would strongly recommand also to go to Eclipse->window->preferences,
then open the C++ tree and click on code style and set it up to be
conform to ns-3 coding style(http://www.nsnam.org/codingstyle.html),
then click on editor and uncheck "Remove trailing whitespaces" this will
avoid you to have to deal with white space changes.
To run the tests and configure (./waf --check and ./waf configure ...)
options you can use external tools configuration not forgetting the
LD_LIBRARY_PATH configuration to indicate the compiled ns3lib.so location.
If you need more details, don't hesitate.
Best regards
Faker Moatamri
Builder1.png
Builder.png

Mihir Daftari

unread,
Aug 5, 2009, 7:39:51 AM8/5/09
to ns-3-...@googlegroups.com
Try this


It shows how you can set up eclipse to build using waf.    Let us know how it goes.. as I will be interested in setting this environment up for myself as well.  Maybe we can have a small "howto" on the wiki somewhere.  

Di

unread,
Aug 5, 2009, 11:19:19 AM8/5/09
to ns-3-users
Faker and Mihir, I tried what you posted, the two ways were basically
the same. However, whenever I click "build all", I get this error:
(Cannot run program "waf": Unknown reason)
I have screenshots of the setup, but how do you post the screenshots?

On Aug 5, 7:39 am, Mihir Daftari <mihir.daft...@gmail.com> wrote:
> Try thishttp://quirkygba.blogspot.com/2009/02/it-has-been-while-since-i-last-...
>
> <http://quirkygba.blogspot.com/2009/02/it-has-been-while-since-i-last-...>It
> shows how you can set up eclipse to build using waf.    Let us know how it
> goes.. as I will be interested in setting this environment up for myself as
> well.  Maybe we can have a small "howto" on the wiki somewhere.
>
> On Wed, Aug 5, 2009 at 4:26 AM, Faker Moatamri <
>
> faker.moata...@sophia.inria.fr> wrote:
> > cb wrote:
> > > I've not tried that yet, but if you stick to C++ you'll just have to
> > > set the relevant paths for the ns3 library (either debug or optimized
> > > version) and headers. for running the program, remember to set
> > > LD_LIBRARY_PATH if you're in linux, or place the ns3 library you want
> > > to use in a system-known location if you're on windows.
>
> > > On Aug 4, 1:26 pm, Di <dizo...@gmail.com> wrote:
>
> > >> I want to be able to build and run NS-3 through eclipse, and I was
> > >> wondering if anyone has done it.
>
> > >> Thanks.
>
> > I use eclipse with ns-3 and I'm pretty happy with it. Here are 2 screen
> > shots of the builder configuration.
> > You can install the mercurial plugin and create a new empty C++ project
> > with eclipse then download it manually to the target directory using hg
> > clonehttp://code.nsnam.org/ns-3-devtargetDir, then on eclipse you

Mihir Daftari

unread,
Aug 5, 2009, 12:53:08 PM8/5/09
to ns-3-...@googlegroups.com
if you are windows try

python <path to your waf script file> 

For example, if your dev directory is in /repos/ns3-allinone/ns-3/ ..  try

python /repos/ns3-allinone/ns-3/waf build   

Di

unread,
Aug 5, 2009, 1:16:31 PM8/5/09
to ns-3-users
I am using Linux. Where does Eclipse look for waf? I tried replaceing
"waf" with "python ~/ns-3-multithreading/waf build" and I get this
error:
python: can't open file '~/ns-3-multithreading/waf': [Errno 2] No such
file or directory

On Aug 5, 12:53 pm, Mihir Daftari <mihir.daft...@gmail.com> wrote:
> if you are windows try
> python <path to your waf script file>
>
> For example, if your dev directory is in /repos/ns3-allinone/ns-3/ ..  try
>
> python /repos/ns3-allinone/ns-3/waf build
>

Mihir Daftari

unread,
Aug 5, 2009, 1:36:39 PM8/5/09
to ns-3-...@googlegroups.com
in your directory ns-3-multithreading do "pwd"

copy that path and paste that instead of the path with ~ ..  

I dont know if it will work or not..  but worth a try.  

Di

unread,
Aug 5, 2009, 2:08:20 PM8/5/09
to ns-3-users
Yes that worked. Thank you.

On Aug 5, 1:36 pm, Mihir Daftari <mihir.daft...@gmail.com> wrote:
> in your directory ns-3-multithreading do "pwd"
> copy that path and paste that instead of the path with ~ ..
>
> I dont know if it will work or not..  but worth a try.
>

Tom Henderson

unread,
Aug 6, 2009, 12:21:08 AM8/6/09
to ns-3-...@googlegroups.com

Faker, do you mind turning the above advice into a HOWTO at some point?
http://www.nsnam.org/wiki/index.php/HOWTOs

- Tom

Faker Moatamri

unread,
Aug 6, 2009, 3:41:00 AM8/6/09
to ns-3-...@googlegroups.com
Yes sure, how can I add a page to the wiki?
Regards
Faker

Di

unread,
Aug 6, 2009, 9:39:46 AM8/6/09
to ns-3-users
For me, in order to run the program properly, a binary parser had to
be set under Project->Properties->C/C++ Build->Settings. After that,
to run the program, click Run As->Local C/C++ Application. Then a
window will pop up asking to choose a local application to run. Select
the application, click OK and the program will run. I have screenshots
I can upload, how do I do that?

On Aug 6, 3:41 am, Faker Moatamri <faker.moata...@sophia.inria.fr>
wrote:
> Tom Henderson wrote:
> > Faker Moatamri wrote:
>
> >> cb wrote:
>
> >>> I've not tried that yet, but if you stick to C++ you'll just have to
> >>> set the relevant paths for the ns3 library (either debug or optimized
> >>> version) and headers. for running the program, remember to set
> >>> LD_LIBRARY_PATH if you're in linux, or place the ns3 library you want
> >>> to use in a system-known location if you're on windows.
>
> >>> On Aug 4, 1:26 pm, Di <dizo...@gmail.com> wrote:
>
> >>>> I want to be able to build and run NS-3 through eclipse, and I was
> >>>> wondering if anyone has done it.
>
> >>>> Thanks.
>
> >> I use eclipse with ns-3 and I'm pretty happy with it. Here are 2 screen
> >> shots of the builder configuration.
> >> You can install the mercurial plugin and create a new empty C++ project
> >> with eclipse then download it manually to the target directory using hg
> >> clonehttp://code.nsnam.org/ns-3-devtargetDir, then on eclipse you

Di

unread,
Aug 6, 2009, 9:47:02 AM8/6/09
to ns-3-users
Also, I am experimenting with two different builds (NS-3-
multithreading and NS-3.5) of NS-3, and I did the exact same thing to
set up this second build of NS-3. However, I cannot run any programs
under my second build. In the console window I get:
<terminated> program_name [C/C++ Application] /program_path/...

In the debug window, I get:
<terminated, exit value: -1> /program_path/

I can get both builds to run in the terminal window using ./waf --run /
program_path/...

Faker Moatamri

unread,
Aug 6, 2009, 9:57:53 AM8/6/09
to ns-3-...@googlegroups.com
For the screen shots I sent them by email as an attachement in the email
sent to the group.
Regards
Faker

Tom Henderson

unread,
Aug 7, 2009, 1:15:35 AM8/7/09
to ns-3-...@googlegroups.com

>> Faker, do you mind turning the above advice into a HOWTO at some point?
>> http://www.nsnam.org/wiki/index.php/HOWTOs
>>
>> - Tom
>>
>>
> Yes sure, how can I add a page to the wiki?
> Regards
> Faker

It is easy, but you need an account enabled for editing (we do not have
an open access wiki because of the spam problems). Create an account
and then send me your account name and I will enable it for editing.

Tom

Mihir Daftari

unread,
Aug 8, 2009, 8:26:21 PM8/8/09
to ns-3-...@googlegroups.com
I was able to setup a project and build the code using eclipse.  But I am having trouble running any program.  

I get the following error when I try and run any program:

dyld: Library not loaded: debug/libns3.dylib

  Referenced from: /Users/mihirdaftari/ns3/ns-3-allinone/ns-3-dev/build/debug/examples/hello-simulator

  Reason: image not found


Any ideas? 


Thanks.  

Tom Henderson

unread,
Aug 9, 2009, 12:57:46 AM8/9/09
to ns-3-...@googlegroups.com
Mihir Daftari wrote:
> I was able to setup a project and build the code using eclipse. But I
> am having trouble running any program.
>
> I get the following error when I try and run any program:
>
> dyld: Library not loaded: debug/libns3.dylib
>
> Referenced from:
> /Users/mihirdaftari/ns3/ns-3-allinone/ns-3-dev/build/debug/examples/hello-simulator
>
> Reason: image not found
>
>
> Any ideas?

I am not familiar with Eclipse but the error you are seeing above is due
to libns3.dylib not being in your DYLD_LIBRARY_PATH for OS X. You can
either set the environment variable DYLD_LIBRARY_PATH to include the
absolute path to libns3.dylib, or else run the program through the waf
shell as in
"./waf --run hello-simulator"


Mihir Daftari

unread,
Aug 9, 2009, 1:23:51 AM8/9/09
to ns-3-...@googlegroups.com
Hi Tom,
I figured it out.  I had added the DYLD_LIBRARY_PATH environment variable for the shell..  But it needs to be done in eclipse.  

Thanks,
Mihir

HyungJune Lee

unread,
Aug 14, 2009, 8:34:28 PM8/14/09
to ns-3-users
Hi Mihir,

I was wondering whether you have already solved this problem.
I also bumped into the exactly same problem, and finally tacked the
problem.
For those who struggle with this problem, I'm writing how I did.

1) Right click on your project
2) Select 'Run As' -> 'Local C/C++ Application'
3) Choose the application which you would like to run
4) This will bring out the following error message, for example

dyld: Library not loaded: debug/libns3.dylib
Referenced from: /Users/abbado/Projects/ns-allinone-3.5/ns-3.5/build/
debug/scratch/first
Reason: image not found

5) Go to 'Run' menu in the top
6) Select 'Run Configurations...'
7) Select the application you tried to run
8) Go to 'Environment' tap
9) You need to create a new variable for the library path
In my setting, I did the following.

Name: DYLD_LIBRARY_PATH
Value: /Users/abbado/Projects/ns-allinone-3.5/ns-3.5/build/debug

Now we can run any ns-3 application in eclipse.

(FYI, I have not added DYLD_LIBRARY_PATH environment variable in the
shell though.)

Thanks,

HyungJune


On Aug 8, 10:23 pm, Mihir Daftari <mihir.daft...@gmail.com> wrote:
> Hi Tom,I figured it out.  I had added the DYLD_LIBRARY_PATH environment
> variable for the shell..  But it needs to be done in eclipse.
>
> Thanks,
> Mihir
>

Mihir Daftari

unread,
Aug 15, 2009, 10:30:00 AM8/15/09
to ns-3-...@googlegroups.com
I was able to figure that out.. thanks for the info though.

Mihir
Reply all
Reply to author
Forward
0 new messages