Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-05-2011, 07:49 AM
|
#1
|
LQ Newbie
Registered: Sep 2011
Posts: 13
Rep:
|
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
|
|
|
09-05-2011, 01:32 PM
|
#2
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
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'.
..
Last edited by knudfl; 09-10-2011 at 05:52 AM.
|
|
1 members found this post helpful.
|
09-12-2011, 01:17 AM
|
#3
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Moved: This thread is more suitable in Linux Software and has been moved accordingly to help your thread/question get the exposure it deserves.
|
|
|
03-28-2012, 09:35 AM
|
#4
|
LQ Newbie
Registered: Mar 2012
Posts: 8
Rep:
|
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.
|
|
|
03-28-2012, 09:53 AM
|
#5
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
# 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
.
|
|
|
03-28-2012, 11:20 AM
|
#6
|
LQ Newbie
Registered: Mar 2012
Posts: 8
Rep:
|
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
Last edited by NimeshaK; 03-28-2012 at 11:23 AM.
|
|
|
03-28-2012, 01:13 PM
|
#7
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
# 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.
Wrong syntax, and not a c program. Use g++ for c++ programs.
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.
.
Last edited by knudfl; 03-28-2012 at 01:17 PM.
|
|
|
03-28-2012, 03:05 PM
|
#8
|
LQ Newbie
Registered: Mar 2012
Posts: 8
Rep:
|
ns-2
I compiled my program with "g++ sim.cc -o sim" command.
It worked well!!
Thank you so much
Last edited by NimeshaK; 03-28-2012 at 03:30 PM.
|
|
|
All times are GMT -5. The time now is 04:31 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|