Converting c++ file to a python file

178 views
Skip to first unread message

mand...@gmail.com

unread,
Aug 25, 2018, 6:04:39 AM8/25/18
to ns-3-users
Hi team,

I am trying to convert a c++ file to a python file and run it using `./waf --pyrun scratch/aodv.py` There I need a way to convert this following line.

#include "myapp.h"

I have tried `import myapp` in python file. But that doesn't work even myapp.h file is in the same scratch folder. So anyone has an idea? 

Thanks & Regards,
Mandula

Message has been deleted

pdbarnes

unread,
Aug 27, 2018, 12:47:07 AM8/27/18
to ns-3-users
ns-3 is implemented in C++. Most of the functionality is made available to Python, through a build process called “binding generation.” You may have seen this discussed on the list.

Examples and things in scratch ARE NOT available in Python. That’s why you’ll find some examples in both C++ and Python, as illustrations of how to use ns-3.

I’m guessing that myapp.h and myapp.cc are your code in scratch, perhaps from following the tutorial? You won’t be able to call that from Python, since bindings aren’t generated for things in scratch.

You *could* put the myapp.h/cc files instead/applications/model/, for example, then the binding process could make myapp accessible in Python. You’ll have to find the instructions on the ns-3 wiki to get that to work.


Peter
Reply all
Reply to author
Forward
0 new messages