NS2 Simulator
Hi, I'm doing a project in ad hoc, in NS2 for simultaion.I need help in simulating C++ codes. Can u say me how to run c++ files using NS2
|
cd ns-allinone-2.34/ns-2.34/ && cp Makefile Makefile-new
&& cp ns ns.orig && make clean Assume test.cc : Add test.o to 'Makefile-new', line 330. ( Section OBJ_CC ). Then run 'make -f Makefile-new' in ns-allinone-2.34/ns-2.34/, and your code will be compiled into the new 'ns'. .. |
Moved: This thread is more suitable in Linux Software and has been moved accordingly to help your thread/question get the exposure it deserves.
|
ns-2
hi,
I changed ns-2 according to the below command as u mentioned. "cd ns-allinone-2.34/ns-2.34/ && cp Makefile Makefile-new && cp ns ns.orig && make clean Assume test.cc : Add test.o to 'Makefile-new', line 330. ( Section OBJ_CC ). Then run 'make -f Makefile-new' in ns-allinone-2.34/ns-2.34/, and your code will be compiled into the new 'ns'." But yet,i cannot find a suitable way 2 complie & run C++ program in ns-2.Please help me. |
# 4
You cannot run a c++ program in ns2. When your new object is compiled into a new binary ns, you can write e.g. a tcl file, that use the new function. And run that file : ./ns file.tcl If you have problems with compiling, please specify your errors. And : Tell which Linux OS, you are using. Like CentOS 6, Fedora 16. Which g++ compiler is used ? ? http://www.linuxquestions.org/linux/...Ask_a_Question http://linuxsilo.net/docs/smart-questions_en.html . |
ns-2
I can run ".tcl" files.But I can't run C++ programs.This is the program i want to run.
//sim.cc main(){ float delay = 0, d_i = 1; int i, num_nodes = 11; for(i = 1; i < num_nodes; i++) delay += d_i; printf("Overall Packet Delay is %2.1f seconds.\n", delay); } I save this as sim.cc.When I give the command to compile "gcc -o sim.cc" ,I get this error."gcc: fatal error: no input files compilation terminated.". What is the wrong in this program? I am using Fedora 14.and ns-2.35 |
# 6 . First : Use CODE tags for code.
Write [/code] at code end, and [code] at code start. Or use the # button in the 'Advanced Editor'. http://www.linuxquestions.org/questi....php?do=bbcode Please edit post # 6 : code tags. Quote:
g++ sim.cc -o sim : Should work ( If it wasn't an ns2 program.) Short : There can only be one binary in ns2 : 'ns' New files must be compiled into 'ns'. Ref. post # 2. If you don't, you will miss "the 300 functions" that make up the simulation. . |
ns-2
I compiled my program with "g++ sim.cc -o sim" command.
It worked well!! Thank you so much |
All times are GMT -5. The time now is 09:49 AM. |