[ndnSIM] Call engine.h in ndnSIM

Alex Afanasyev alexander.afanasyev at ucla.edu
Thu Nov 14 15:59:21 PST 2013


Hi Amin,

Files you put in scratch are compiled only against NS-3 modules, so you're bound to fail if you want to link against MATLAB.

When you move to the examples folder, you have to edit the corresponsing wscript and in the wscript you specify name of the application, as I suggested before, which you will be using ./waf --run. 

---
Alex

On Nov 14, 2013, at 2:59 PM, Amin Karami <amin at ac.upc.edu> wrote:

> I configured NS-3 with examples, but it shows the same error: program 'simple' not found; ....
> But, when I copied simple.cc program into /scratch folder, it is executing. I cannot call it in /scratch?
> Another question is that, when i add MATLAB engine and requirement libraries into wscript files, i need again include it in my simple.cc program?
> 
> /Amin
> 
> On 11/14/2013 11:07 ب.ظ, Alex Afanasyev wrote:
>> If you haven't configured your NS-3 with examples before, then ./waf configure --enable-examples should fix it.
>> 
>> ---
>> Alex
>> 
>> On Nov 14, 2013, at 12:46 PM, Amin Karami <amin at ac.upc.edu> wrote:
>> 
>>> Hi Alex,
>>> 
>>> I just shift the 2nd command to end of the page and the problem was fixed!
>>> I put my scenario (simple.cc) into src/ndnSIM/example folder. But when I run this program it gives error: program 'simple' not found; available programs are ...
>>> 
>>> But for other program in this folder (e.g., ndn-simple), simulator works.
>>> 
>>> What is the problem?
>>> I think i need run "./waf configure --enable-examples" again. Yes?
>>> 
>>> 
>>> 
>>> Best Regards,
>>> Amin
>>> 
>>> On 11/14/2013 09:14 ب.ظ, Alex Afanasyev wrote:
>>>> Hi Amin,
>>>> 
>>>> Python scripts (wscript) are very sensitive to indentation. You should correct the things you have typed to match indentation of the existing code.
>>>> 
>>>> ---
>>>> Alex
>>>> 
>>>> On Nov 14, 2013, at 12:12 PM, Amin Karami <amin at ac.upc.edu> wrote:
>>>> 
>>>>> Hi Alex,
>>>>> Thank you for your guidance. I ran your suggested commands but i faced with errors:
>>>>> 
>>>>> Traceback (most recent call last):
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/.waf-1.7.11-2f760793a9090bf35f69082a250595d9/waflib/Scripting.py", line 97, in waf_entry_point
>>>>> run_commands()
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/.waf-1.7.11-2f760793a9090bf35f69082a250595d9/waflib/Scripting.py", line 149, in run_commands
>>>>> parse_options()
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/.waf-1.7.11-2f760793a9090bf35f69082a250595d9/waflib/Scripting.py", line 127, in parse_options
>>>>> Context.create_context('options').execute()
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/.waf-1.7.11-2f760793a9090bf35f69082a250595d9/waflib/Options.py", line 134, in execute
>>>>> super(OptionsContext,self).execute()
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/.waf-1.7.11-2f760793a9090bf35f69082a250595d9/waflib/Context.py", line 87, in execute
>>>>> self.recurse([os.path.dirname(g_module.root_path)])
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/.waf-1.7.11-2f760793a9090bf35f69082a250595d9/waflib/Context.py", line 128, in recurse
>>>>> user_function(self)
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/wscript", line 209, in options
>>>>> opt.recurse('src')
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/.waf-1.7.11-2f760793a9090bf35f69082a250595d9/waflib/Context.py", line 128, in recurse
>>>>> user_function(self)
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/src/wscript", line 47, in options
>>>>> opt.recurse(module, mandatory=False)
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/.waf-1.7.11-2f760793a9090bf35f69082a250595d9/waflib/Context.py", line 122, in recurse
>>>>> wscript_module=load_module(node.abspath())
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/.waf-1.7.11-2f760793a9090bf35f69082a250595d9/waflib/Context.py", line 281, in load_module
>>>>> exec(compile(code,path,'exec'),module.__dict__)
>>>>> File "/home/bluebit/Documents/ndnSIM/ns-3/src/ndnSIM/wscript", line 42
>>>>> conf.env['ENABLE_NDNSIM']=False;
>>>>> ^
>>>>> IndentationError: unindent does not match any outer indentation level
>>>>> 
>>>>> 
>>>>> 
>>>>> On 11/14/2013 05:07 ب.ظ, Alex Afanasyev wrote:
>>>>>> Hi Amin,
>>>>>> 
>>>>>> The problem is that you need to specify that your program needs to be compiled with MATLAB dependency (with proper CXXFLAGS and LINKFLAGS).  I'm not quite confident how to do it with scratch/ folder, but if you have created a separate scenario repository or configured your scenario in src/ndnSIM/examples/wscript (and put it under src/ndnSIM/examples), then you may do the following:
>>>>>> 
>>>>>> 1. Edit src/ndnSIM/wscript
>>>>>> 
>>>>>> somewhere (in the beginning) of `def configure(conf):`
>>>>>> 
>>>>>> conf.env['INCLUDES_MATLAB'] = '<path-to-matlab-folder-where-engine.h-exists>'
>>>>>> conf.env['LIB_MATLAB'] = ['<matlab-library>']
>>>>>> conf.env['LIBPATH_MATLAB'] = '<path-to-matlab-library>'
>>>>>> 
>>>>>> 
>>>>>> I'm not sure, but according some Internet posts, the second line should be something like:
>>>>>> 
>>>>>> conf.env['LIB_MATLAB'] = ['eng', 'mat', 'mx']
>>>>>> 
>>>>>> and third should be location of libeng.dylib/libeng.so, libmat.dylb/libmat.so, libmx.dylib/libmx.so libraries within MATLAB
>>>>>> 
>>>>>> 
>>>>>> 2. Edit src/ndnSIM/examples/wscript
>>>>>> 
>>>>>> Edit/create definition for your program to look like this
>>>>>> 
>>>>>>     obj = bld.create_ns3_program('your-app', all_modules)
>>>>>>     obj.source = 'your-app.cc'
>>>>>>     obj.use += ['MATLAB']
>>>>>> 
>>>>>> ---
>>>>>> Alex
>>>>>> 
>>>>>> 
>>>>>> On Nov 13, 2013, at 3:47 PM, Amin Karami <amin at ac.upc.edu> wrote:
>>>>>> 
>>>>>>> Hi,
>>>>>>> I want to call MATLAB engine into the my scenario in ndnSIM by #include "engine.h"
>>>>>>> But, i received this error:
>>>>>>> ../scratch/simple.cc:5:20: fatal error: engine.h: No such file or directory
>>>>>>> compilation terminated.
>>>>>>> 
>>>>>>> Also, i included the complete route of the engine.h, but i faced with the same error as follows. Again, i copied the engine.h next to the simple.cc file. but i faced with the same error.
>>>>>>> 
>>>>>>> How is it possible to call this engine?
>>>>>>> 
>>>>>>> 
>>>>>>> Best Regards,
>>>>>>> Amin
>>> _______________________________________________
>>> ndnSIM mailing list
>>> ndnSIM at lists.cs.ucla.edu
>>> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
> _______________________________________________
> ndnSIM mailing list
> ndnSIM at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim





More information about the ndnSIM mailing list