how to solve this error

470 views
Skip to first unread message

nagy....@fa-hists.edu.eg

unread,
May 30, 2014, 4:32:24 PM5/30/14
to ns-3-...@googlegroups.com
remon@ubuntu:~/ns-allinone-3.19/ns-3.19$ ./waf --run myaodv
Waf: Entering directory `/home/remon/ns-allinone-3.19/ns-3.19/build'
[ 800/1694] cxx: scratch/myaodv.cc -> build/scratch/myaodv.cc.1.o
../scratch/myaodv.cc: In member function ‘void AodvExample::Run()’:
../scratch/myaodv.cc:137:1: error: expected primary-expression before ‘/’ token
 /Simulator::Stop (Seconds (totalTime));
 ^
../scratch/myaodv.cc:138:22: error: no matching function for call to ‘ns3::AnimationInterface::AnimationInterface()’
   AnimationInterface anim;
                      ^
../scratch/myaodv.cc:138:22: note: candidates are:
In file included from ./ns3/netanim-module.h:11:0,
                 from ../scratch/myaodv.cc:22:
./ns3/animation-interface.h:120:3: note: ns3::AnimationInterface::AnimationInterface(std::string, uint64_t, bool)
   AnimationInterface (const std::string filename,
   ^
./ns3/animation-interface.h:120:3: note:   candidate expects 3 arguments, 0 provided
./ns3/animation-interface.h:106:7: note: ns3::AnimationInterface::AnimationInterface(const ns3::AnimationInterface&)
 class AnimationInterface
       ^
./ns3/animation-interface.h:106:7: note:   candidate expects 1 argument, 0 provided
./ns3/animation-interface.h:471:8: error: ‘bool ns3::AnimationInterface::SetOutputFile(const string&)’ is private
   bool SetOutputFile (const std::string& fn);
        ^
../scratch/myaodv.cc:139:33: error: within this context
   anim.SetOutputFile ("aodv.xml");
                                 ^
In file included from ./ns3/netanim-module.h:11:0,
                 from ../scratch/myaodv.cc:22:
./ns3/animation-interface.h:481:8: error: ‘void ns3::AnimationInterface::SetXMLOutput()’ is private
   void SetXMLOutput ();
        ^
../scratch/myaodv.cc:140:22: error: within this context
   anim.SetXMLOutput ();
                      ^
In file included from ./ns3/netanim-module.h:11:0,
                 from ../scratch/myaodv.cc:22:
./ns3/animation-interface.h:494:8: error: ‘void ns3::AnimationInterface::StartAnimation(bool)’ is private
   void StartAnimation (bool restart = false);
        ^
../scratch/myaodv.cc:141:24: error: within this context
   anim.StartAnimation ();
                        ^
Waf: Leaving directory `/home/remon/ns-allinone-3.19/ns-3.19/build'
Build failed
 -> task in 'myaodv' failed (exit status 1):
    {task 150997132: cxx myaodv.cc -> myaodv.cc.1.o}
['/usr/bin/g++', '-O0', '-ggdb', '-g3', '-Wall', '-Werror', '-Wno-error=deprecated-declarations', '-fstrict-aliasing', '-Wstrict-aliasing', '-pthread', '-pthread', '-fno-strict-aliasing', '-fwrapv', '-fstack-protector', '-fno-strict-aliasing', '-I.', '-I..', '-I/usr/include/gtk-2.0', '-I/usr/lib/i386-linux-gnu/gtk-2.0/include', '-I/usr/include/atk-1.0', '-I/usr/include/cairo', '-I/usr/include/gdk-pixbuf-2.0', '-I/usr/include/pango-1.0', '-I/usr/include/gio-unix-2.0', '-I/usr/include/glib-2.0', '-I/usr/lib/i386-linux-gnu/glib-2.0/include', '-I/usr/include/pixman-1', '-I/usr/include/freetype2', '-I/usr/include/libpng12', '-I/usr/include/harfbuzz', '-I/usr/include/libxml2', '-I/usr/include/python2.7', '-I/usr/include/i386-linux-gnu/python2.7', '-DNS3_ASSERT_ENABLE', '-DNS3_LOG_ENABLE', '-DHAVE_SYS_IOCTL_H=1', '-DHAVE_IF_NETS_H=1', '-DHAVE_NET_ETHERNET_H=1', '-DHAVE_PACKET_H=1', '-DHAVE_SQLITE3=1', '-DHAVE_IF_TUN_H=1', '-DHAVE_GSL=1', '-DNDEBUG', '-D_FORTIFY_SOURCE=2', '../scratch/myaodv.cc', '-c', '-o', 'scratch/myaodv.cc.1.o']

Tommaso Pecorella

unread,
May 30, 2014, 6:12:33 PM5/30/14
to ns-3-...@googlegroups.com
The first one is because you did instantiate the AnimationInterface in the wrong way.
The correct one is:
AnimationInterface anim ("somefilename.xml");

The other ones may disappear upon fixing the first. If they don't, please refer to a working example to check the correct use pattern. E.g., 

examples//wireless/mixed-wireless.c


T.

nagy....@fa-hists.edu.eg

unread,
May 31, 2014, 3:58:40 AM5/31/14
to ns-3-...@googlegroups.com
 i try it but no solution please anyone help me to solve this problem thanks



On Friday, May 30, 2014 10:32:24 PM UTC+2, nagy....@fa-hists.edu.eg wrote:

Tommaso Pecorella

unread,
May 31, 2014, 4:10:41 AM5/31/14
to ns-3-...@googlegroups.com
No.

Sorry, we can't fix your problem, due to your code, in your computer. You just shared the errors the compiler is printing, which barely show the erroneous lines.

From the solution to the first error, it is clear that you did severe mistakes in code. And more importantly, you did not even check the examples and the code documentation (you tried to use a private constructor).
The fist error solution should had given you one indication, above everything. You have to check the documentation or (at least) a working example.

Now, if you want you can post your code (in an attachment, mind) and we'll see what's wrong. However, be prepared, because I am 99.99% confident that the errors will only confirm that you didn't read the docs.

T.
Message has been deleted

Tommaso Pecorella

unread,
May 31, 2014, 8:19:30 AM5/31/14
to ns-3-...@googlegroups.com
Hi,

don't tell I didn't warn you. You called for it, now you'll get what you deserve.

Line 45:
class AodvExample
{
   
void ns3::AnimationInterface::StartAnimation(bool);
...

What is doing this function declaration here ?
I mean... it looks like a function declaration, and it is in a class. Thus, it is a member function, but the double "::" means something else. You're declaring a function for another class here !
What a mess... but the real question is: WHY is this here? What was the goal ?
Remove it.

Lines 138-139:
  AnimationInterface anim ("somefilename.xml");

 
AnimationInterface anim;
anim is defined TWICE. The second one is not legal (told you before).
Remove the second line

Lines 140, 141, 142
  anim.SetOutputFile ("aodv.xml");
  anim
.SetXMLOutput ();
  anim
.StartAnimation ();
CONGRATULATIONS. Three private functions !
Not one, THREE. Do you know that private functions can not be used ?
Heck, you didn't read the documentation for sure.
Remove them altogether. You can NOT use them and they're called automatically when needed anyway.

Conclusions. These aren't ns-3 mistakes, those are C++ issues. I'll be nice and I'll give you a suggestion: study the very basics of C++. You need 'em.
Focus on the following topics:
1) Classes and inheritance
2) member functions and variables, exp. the difference between private, public and protected.


T.

On Saturday, May 31, 2014 11:07:51 AM UTC+2, nagy....@fa-hists.edu.eg wrote:

this is the file when run it see this error thanks

On Friday, May 30, 2014 10:32:24 PM UTC+2, nagy....@fa-hists.edu.eg wrote:
Reply all
Reply to author
Forward
0 new messages