Running C++ program in NS-3

1,065 views
Skip to first unread message

manoj...@gmail.com

unread,
Jun 7, 2013, 5:11:43 AM6/7/13
to ns-3-...@googlegroups.com
Hi guys...
I have written a C++ program named main.cpp which has a header (user defined file) named FiniteFieldElement.hpp.
All the example programs in NS-3 have the extension ".cc" like first.cc, second.cc and the header files as ".h"
    
        1) Should my program also have the extension ".cc" or it is ok with ".cpp"    
       
        2) I have copied my main.cpp to scratch, should I copy FiniteFieldElement.hpp also ?

        3) I have tried copying both files as it is (.cpp and .hpp) it is showing the error "Program main not found".

        4) I have also tried making those files as .cc and .h files - it is not building/compiling only. It is showing some errors in main.cc

Please help me out...

manoj...@gmail.com

unread,
Jun 10, 2013, 3:35:08 AM6/10/13
to ns-3-...@googlegroups.com
I have tried both the extensions, It is not considering ".cpp" for compiling and it is giving error for ".cc". But i am getting output for the same program with g++ compiler. Its showing so many errors regarding "ostream". I have used ostream in the program.

On Monday, June 10, 2013 12:53:18 PM UTC+5:30, Alexander William wrote:
Hi, have you tried to copy only the file to scratch and try to compile it using : ./waf --run scratch/main 
I think, you should have the extension ".cc" for your program.

regards,

Alexander William

Junling Bu

unread,
Jun 10, 2013, 3:44:06 AM6/10/13
to ns-3-...@googlegroups.com
Hi, I think you'd better add .cc and .h file both in scratch, and then use ./waf to compile and use ./waf --run scratch/main as Alexander says.
If here is errors, maybe it is because your code  not write right.
why not show your code and error output?

Konstantinos

unread,
Jun 10, 2013, 6:00:28 AM6/10/13
to ns-3-...@googlegroups.com
The ostream is an 'std' namespace class. When you compile it with ./waf you have to either declare with namespace you use at the beginning or use it directly in the code like this std::ostream. 

But as Junling Bu said, it would be easier to help you if you posted the errors and/or code snippets.

manoj...@gmail.com

unread,
Jun 10, 2013, 12:39:13 AM6/10/13
to ns-3-...@googlegroups.com
Hi guys.. Please help me out for this problem.... I am not able to run this program in NS-3.. I have explained in detail waht's the problem.

Alexander William

unread,
Jun 10, 2013, 3:23:18 AM6/10/13
to ns-3-...@googlegroups.com
Hi, have you tried to copy only the file to scratch and try to compile it using : ./waf --run scratch/main 
I think, you should have the extension ".cc" for your program.

regards,

Alexander William

Pada Jumat, 07 Juni 2013 16:11:43 UTC+7, manoj...@gmail.com menulis:
Reply all
Reply to author
Forward
0 new messages