Integration of ns-3 into the Xcode IDE

501 views
Skip to first unread message

noel.fa...@gmail.com

unread,
Aug 14, 2016, 10:31:36 AM8/14/16
to ns-3-users
Hi all,

I apologise if this question was already asked, however, I didn't find any solution.

I have managed to compile ns-3 on OSX v10.11.6 by installing Xcode and the developer command line tools.
What I tried to do was to integrate the Xcode IDE with ns3, however I wasn't able to. I've tried to google for
a walkthrough (similar like to what there is for QtCreator, NetBeans and Eclipse) but I didn't manage to find
any.

Is there a way that I can compile,debug and run ns-3 code using the Xcode IDE? And if so, how do I go about it?

Thanks a lot for your time. Much appreciated.

Cheers,
Noel

Tommaso Pecorella

unread,
Aug 14, 2016, 6:17:12 PM8/14/16
to ns-3-users
Hi Noel,

I have no idea about how to integrate them, but it should be possible.
If you find a way, I'll be more than happy to expand the wiki.

Cheers,

T.

noel.fa...@gmail.com

unread,
Aug 15, 2016, 3:26:08 AM8/15/16
to ns-3-users
Hi Tommaso,

I tried to integrate it myself but I could not manage to do it. I've tried setting it up similar to the QtCreator with the included header files and created a project with custom build process but to no avail. This is my first time using the Xcode IDE which is why I got stuck so easily. If there's anyone that can give me any pointers I'll be happy to give it another go.

Thanks a lot for your time.

Cheers,
Noel

noel.fa...@gmail.com

unread,
Aug 15, 2016, 4:09:46 AM8/15/16
to ns-3-users
Hi Tommaso,

I did some more research this morning and it turns out that the waf script is capable of creating an Xcode project (https://github.com/waf-project/waf).

By default this feature is not enabled and to enable it we need to pass "--tools=xcode" to the waf-light script similar to "./waf-light --tools=xcode" (https://github.com/waf-project/waf/issues/1397http://stackoverflow.com/questions/22189764/generate-xcode-project-with-waf ).

I tried to download waf from github and generate a new waf using the tools Xcode option but when I was trying to build ns3 it failed.
My thinking is that the waf generated by ns3 either has some other command line options or I'm using an incorrect version.
Do you think you have any pointers on how I can generate the waf file with the Xcode option, or if you have the updated waf I can easily try it out.

Thanks a lot for your time. Much appreciated.

Cheers,
Noel

Tommaso Pecorella

unread,
Aug 15, 2016, 8:10:48 AM8/15/16
to ns-3-users, Vedran Miletić
Hi Noel,

Vedran (who's reading us in cc) is more expert than me in waf. Perhaps he knows how to use that option.

Cheers,

T.

Matt Anonyme

unread,
Aug 16, 2016, 9:23:18 AM8/16/16
to ns-3-users, riv...@gmail.com
waf can apparently generate projects for some IDEs, it was discussed (during the windows support at last WNS3). Ns3 adds waf extensions in the "waf-tools" folder so adding the plugin there and following hte stackoverflow advice should be enough.

What is your error ?

noel.fa...@gmail.com

unread,
Aug 16, 2016, 9:57:02 AM8/16/16
to ns-3-users, riv...@gmail.com
Hi Matt,

Thank you for your reply. 

I am getting two different errors so I'll explain what I'm doing in both. I apologise if I'm skipping a very small step but I am not very familiar with waf.
I downloaded Waf from https://github.com/waf-project/waf.

In both cases I copied xcode.py and xcode6.py from waflib/extras/ to ns-3.25/waf-tools and added
    opt.load('xcode')
in ns3's wscript file line 148.

Using the WAF provided with ns-3

Running the command ./waf configure will return:

Traceback (most recent call last):

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Scripting.py", line 110, in waf_entry_point

    run_commands()

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Scripting.py", line 167, in run_commands

    parse_options()

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Scripting.py", line 140, in parse_options

    Context.create_context('options').execute()

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Options.py", line 146, in execute

    super(OptionsContext,self).execute()

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 93, in execute

    self.recurse([os.path.dirname(g_module.root_path)])

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 134, in recurse

    user_function(self)

  File "/Users/noelfarrugia/repos/ns-3.25/wscript", line 148, in options

    opt.load('xcode')

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 87, in load

    module=load_tool(t,path,with_sys_path=with_sys_path)

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 387, in load_tool

    __import__(tool)

ImportError: No module named xcode


Generating new waf

Using the downloaded repository I generated a new waf executable using the following command:
    ./waf-light --make-waf --tools=xcode

I copied the resultant waf file into the ns3 directory and issued the same command:
    ./waf configure xcode

The output this time is:

Setting top to                           : /Users/noelfarrugia/repos/ns-3.25 

Setting out to                           : /Users/noelfarrugia/repos/ns-3.25/build 

Checking for 'clang' (C compiler)        : /usr/bin/clang 

Checking for cc version                  : 7.3.0 

Checking for 'clang++' (C++ compiler)    : /usr/bin/clang++ 

Traceback (most recent call last):

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Scripting.py", line 120, in waf_entry_point

    run_commands()

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Scripting.py", line 181, in run_commands

    ctx=run_command(cmd_name)

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Scripting.py", line 172, in run_command

    ctx.execute()

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Configure.py", line 85, in execute

    super(ConfigurationContext,self).execute()

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Context.py", line 88, in execute

    self.recurse([os.path.dirname(g_module.root_path)])

  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Context.py", line 129, in recurse

    user_function(self)

  File "/Users/noelfarrugia/repos/ns-3.25/wscript", line 390, in configure

    if Options.platform == 'darwin':

AttributeError: 'module' object has no attribute 'platform'



Thanks a lot for your time. If you require further information let me know. Much appreciated.

Kind Regards,
Noel

Matt

unread,
Aug 16, 2016, 10:59:31 AM8/16/16
to ns-3-users, Vedran Miletić
If you look in the wscript you will find an extraparameter, try with
that parameter:
conf.load('command', tooldir=['waf-tools'])
> --
> Posting to this group should follow these guidelines
> https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ns-3-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ns-3-users/KMG2bN1SKf8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ns-3-users+...@googlegroups.com.
> To post to this group, send email to ns-3-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/ns-3-users.
> For more options, visit https://groups.google.com/d/optout.

Noel Farrugia

unread,
Aug 16, 2016, 11:07:37 AM8/16/16
to ns-3-...@googlegroups.com, Vedran Miletić
I inserted
conf.load('xcode', tooldir=['waf-tools’])
in wscript line 327 

in ns3’s wscript and using the newly generated waf but the same error is being generated:

./waf configure xcode

Setting top to                           : /Users/noelfarrugia/repos/ns-3.25 
Setting out to                           : /Users/noelfarrugia/repos/ns-3.25/build 
Checking for 'clang' (C compiler)        : /usr/bin/clang 
Checking for cc version                  : 7.3.0 
Checking for 'clang++' (C++ compiler)    : /usr/bin/clang++ 
Traceback (most recent call last):
  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Scripting.py", line 120, in waf_entry_point
    run_commands()
  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Scripting.py", line 181, in run_commands
    ctx=run_command(cmd_name)
  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Scripting.py", line 172, in run_command
    ctx.execute()
  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Configure.py", line 85, in execute
    super(ConfigurationContext,self).execute()
  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Context.py", line 88, in execute
    self.recurse([os.path.dirname(g_module.root_path)])
  File "/Users/noelfarrugia/repos/ns-3.25/.waf-1.9.2-282a71bc325f5e88dbb95e0369c93fbd/waflib/Context.py", line 129, in recurse
    user_function(self)
  File "/Users/noelfarrugia/repos/ns-3.25/wscript", line 391, in configure
    if Options.platform == 'darwin':
AttributeError: 'module' object has no attribute ‘platform'

What I noticed differently this time is that in the waf-tools directory I have a file called xcode.pyc that wasn’t there before.

Thanks again for your time and assistance.

Cheers,
Noel

Matt

unread,
Aug 16, 2016, 11:21:43 AM8/16/16
to ns-3-users, Vedran Miletić
pyc means that the xcode module was compiled. The error you have seems
like a bug. I don't use mac but vedrna might be able to help.

Vedran Miletić

unread,
Aug 22, 2016, 11:39:20 AM8/22/16
to Matt, Noel Farrugia, ns-3-users
Hi Noel, Matt,

sorry for the delay, I was on a vacation and was not reading e-mail.

Now, I don't use a Mac either, but I would expect this Waf extension
to just work(tm). Noel, are you sure you are using the matching
version? These kind of AttributeErrors are due to Waf API changes
between versions.

Regards,
Vedran
--
Vedran Miletić
vedran.miletic.net

Noel Farrugia

unread,
Aug 22, 2016, 12:20:19 PM8/22/16
to Vedran Miletić, Matt, ns-3-users
Hi Vedran,

I hope your vacation was a good one :-).

Can you elaborate on what you mean by "are using the matching version?", in other words how can I build the waf executable such that it matches the one that ns-3 uses please?

Thanks a lot for your time.

Kind Regards,
Noel

Matt

unread,
Aug 22, 2016, 12:21:34 PM8/22/16
to Noel Farrugia, Vedran Miletić, ns-3-users
Dunno if it's the simpler solution but you can clone the waf
repository, checkout the version that matches waf and then copy that
version of the script to ns3.

good luck

Noel Farrugia

unread,
Aug 22, 2016, 12:30:45 PM8/22/16
to Matt, Vedran Miletić, ns-3-users
I'll try that and keep you posted.

Thank you for your help :-)

Noel Farrugia

unread,
Aug 22, 2016, 1:26:14 PM8/22/16
to Matt, Vedran Miletić, ns-3-users
Hello Everyone,

I've manage to generate an Xcode project but it's not ideal.

I'll post the steps I took just in case:

1. I downloaded waf 1.9.2 from https://github.com/waf-project/waf/tree/waf-1.9.2 because that is the version that ns-3.25 use (./waf --version)

2. Compiled waf using ./waf-light --make-waf --tools=xcode

3. Replace the ns-3.25 waf file with the one generated in step 2.

3. Add conf.load('xcode', tooldir=['waf-tools’]) in wscript line 327

4.  Copy xcode.py from <waf-dir>/waflib/extras/ to ns-3.25/waf-tools/

5. Run ./waf configure xcode to build an xcode project

Although the generated project is not ideal (it will build ns3 but no autocomplete, no debugging, and the generated folder structure is a mess) it might help somebody else.

Thank you everyone for your help. Much appreciated.

Kind Regards,
Noel

Matt

unread,
Aug 22, 2016, 1:30:18 PM8/22/16
to Noel Farrugia, Vedran Miletić, ns-3-users
I think some people might be interested in this, tommaso uses mac IMO.
If it's upstreamed it can be improved.

I believe Xcode relies on clang so it should be able to make use of
the build/compile_commands.json generated by waf for its
autocompletion, try looking into that (else you can use
deoplete/YouCompleteMe in vim to have semantic autocompletion).

Cheers

Tommaso Pecorella

unread,
Aug 22, 2016, 6:57:12 PM8/22/16
to ns-3-users, matt...@gmail.com, riv...@gmail.com
Hi,

it's a step ahead. I'm going to be offline for a week, but I can check it when I'll be back.

Cheers,

T.

Matt

unread,
Aug 22, 2016, 7:03:45 PM8/22/16
to Tommaso Pecorella, ns-3-users, Vedran Miletić
It's especially interesting because during last WNS3, some advocated
that cmake could generate project files for IDEs. Apparently waf can
for some major IDEs as well (like visual studio) and with bash on
windows, everything becomes possible :)

Vedran Miletić

unread,
Aug 23, 2016, 1:49:10 PM8/23/16
to Noel Farrugia, Matt, ns-3-users
016-08-22 19:26 GMT+02:00 Noel Farrugia <noel.fa...@gmail.com>:
> Hello Everyone,
>
> I've manage to generate an Xcode project but it's not ideal.
>
> I'll post the steps I took just in case:
>
> 1. I downloaded waf 1.9.2 from
> https://github.com/waf-project/waf/tree/waf-1.9.2 because that is the
> version that ns-3.25 use (./waf --version)
>
> 2. Compiled waf using ./waf-light --make-waf --tools=xcode
>
> 3. Replace the ns-3.25 waf file with the one generated in step 2.
>
> 3. Add conf.load('xcode', tooldir=['waf-tools’]) in wscript line 327
>
> 4. Copy xcode.py from <waf-dir>/waflib/extras/ to ns-3.25/waf-tools/
>
> 5. Run ./waf configure xcode to build an xcode project
>
> Although the generated project is not ideal (it will build ns3 but no
> autocomplete, no debugging, and the generated folder structure is a mess) it
> might help somebody else.
>
> Thank you everyone for your help. Much appreciated.
>
> Kind Regards,
> Noel
>

I'm surprised you did not experience any breakage from upgrading Waf
to 1.9. If you want to use Waf 1.9 with ns-3, you should try the
following patch: https://codereview.appspot.com/247310043/

I can't say whether the patch itself will help with autocomplete and
the rest since I don't use Xcode, but it's worth a shot.

Regards,
Vedran

--
Vedran Miletić
vedran.miletic.net

noel.fa...@gmail.com

unread,
Aug 24, 2016, 3:31:09 AM8/24/16
to ns-3-users, noel.fa...@gmail.com, matt...@gmail.com
Hi Vedran,

I'll try using waf v1.8.19 which ns-3.25 is using and will keep you updated on
the generated Xcode project.

Thank you for pointing this out.

Cheers,
Noel

noel.fa...@gmail.com

unread,
Aug 30, 2016, 11:14:14 AM8/30/16
to ns-3-users, noel.fa...@gmail.com, matt...@gmail.com
Hi all,

I've tried the following steps using Waf 1.8.19 but the outcome is still the same.

Cheers,
Noel
Reply all
Reply to author
Forward
0 new messages