Adding 'include' directories to the waf build

1,911 views
Skip to first unread message

tomh...@mac.com

unread,
Mar 4, 2009, 5:48:57 AM3/4/09
to ns-3-users
Hi,

I'm trying to compile a program in NS-3 that has '#include "mpi.h"' as
part of it. But the system cannot see the include directory for this
header.

Is there a way of adding include directories to waf, so that it can
see them when compiling. I have checked the waf documentation and
help.

In the waf documentation, the following is an example of how to add
includes to programs, but I am unsure where this should be added
(wscript maybe?) so it can act globally in NS.

def build(bld):
bld.new_task_gen(
features='cxx cprogram',
source='main.cpp',
target='test',
includes='. .. ../../')

I have tried adding the full path to mpi.h, but this has further
dependencies in it's include folder, so i wish to add the whole folder
to the waf build path. Is this possible?

Many thanks,

Tom.

Gustavo Carneiro

unread,
Mar 4, 2009, 6:09:38 AM3/4/09
to ns-3-...@googlegroups.com




Hi,

I'm trying to compile a program in NS-3 that has '#include "mpi.h"' as
part of it.  But the system cannot see the include directory for this
header.

Is there a way of adding include directories to waf, so that it can
see them when compiling.  I have checked the waf documentation and
help.

In the waf documentation, the following is an example of how to add
includes to programs, but I am unsure where this should be added
(wscript maybe?) so it can act globally in NS.

def build(bld):
       bld.new_task_gen(
               features='cxx cprogram',
               source='main.cpp',
               target='test',
               includes='. .. ../../')
 
This is what to do to add a directory *belonging to the project itself* to the include path.  Normally to add an external include directory you have to do (for example):

def build(bld):
       obj = bld.new_task_gen(...)
       obj.env.append_value('CPPPATH', '/usr/include/mpi')





I have tried adding the full path to mpi.h, but this has further
dependencies in it's include folder, so i wish to add the whole folder
to the waf build path. Is this possible?

Many thanks,

Tom.




--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert

tomh...@mac.com

unread,
Mar 4, 2009, 6:11:34 AM3/4/09
to ns-3-users
Thanks Gustavo,

Just to clarify, where does this need to be added, my C++ code or in
waf somewhere?

T.

On Mar 4, 11:09 am, Gustavo Carneiro <gjcarne...@gmail.com> wrote:
> 2009/3/4 TomHe...@mac.com <tomhe...@mac.com>

tomh...@mac.com

unread,
Mar 4, 2009, 6:20:22 AM3/4/09
to ns-3-users
Sorry, meant to ask, does htis require a wscript in the scratch
folder?

Gustavo Carneiro

unread,
Mar 4, 2009, 6:24:45 AM3/4/09
to ns-3-...@googlegroups.com




Sorry, meant to ask, does htis require a wscript in the scratch
folder?

Oh, you are using the scratch folder...

I guess you can hack it away for all scratch programs.  See attached patch.
 
p.diff

tomh...@mac.com

unread,
Mar 4, 2009, 6:42:41 AM3/4/09
to ns-3-users
That's perfect. Thanks so much Gustavo.

Tom.
>  p.diff
> < 1KViewDownload

Farhan

unread,
Mar 5, 2009, 7:50:18 PM3/5/09
to ns-3-users

On Mar 4, 10:24 pm, Gustavo Carneiro <gjcarne...@gmail.com> wrote:
>
> Oh, you are using the scratch folder...
>
> I guess you can hack it away for all scratch programs. See attached patch.

So far all my code is done in the scratch folder (as done in the
examples in the documentation). What would I have to do if I wanted to
run from a different folder?

Gustavo Carneiro

unread,
Mar 6, 2009, 5:45:27 AM3/6/09
to ns-3-...@googlegroups.com


2009/3/6 Farhan <farhan...@gmail.com>

1. Open the toplevel wscript file
2. Search for the line:
    bld.add_subdirs('samples utils examples')
3. Add a new similar line:
    bld.add_subdirs('mystuff')
4. Create the directory mystuff
5. Copy examples/wscript as mystuff/wscript and modify to suit your needs
 


Reply all
Reply to author
Forward
0 new messages