undefined reference to `ns3::AnimationInterface::AnimationInterface(std::__cxx11::basic_版本ns3.40
·
现象
如题,在运行ns3-gym的时候想加入anim,图文并茂,但常规地加入头文件和声明报错如下:
~/ns-3.40/contrib/opengym/examples/linear-mesh/sim.cc:913:(.text.unlikely+0x1377): undefined reference to `ns3::AnimationInterface::~AnimationInterface()'
/usr/bin/ld: CMakeFiles/linear-mesh.dir/linear-mesh/sim.cc.o: in function `main':
~/ns-3.40/contrib/opengym/examples/linear-mesh/sim.cc:888:(.text.startup+0x4b7d): undefined reference to `ns3::AnimationInterface::AnimationInterface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: ~/ns-3.40/contrib/opengym/examples/linear-mesh/sim.cc:895:(.text.startup+0x4be9): undefined reference to `ns3::AnimationInterface::UpdateNodeColor(ns3::Ptr<ns3::Node>, unsigned char, unsigned char, unsigned char)'
/usr/bin/ld: ~/ns-3.40/contrib/opengym/examples/linear-mesh/sim.cc:894:(.text.startup+0x4c4b): undefined reference to `ns3::AnimationInterface::UpdateNodeDescription(ns3::Ptr<ns3::Node>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: ~/ns-3.40/contrib/opengym/examples/linear-mesh/sim.cc:897:(.text.startup+0x4cab): undefined reference to `ns3::AnimationInterface::UpdateNodeDescription(ns3::Ptr<ns3::Node>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: ~/ns-3.40/contrib/opengym/examples/linear-mesh/sim.cc:898:(.text.startup+0x4cf1): undefined reference to `ns3::AnimationInterface::UpdateNodeColor(ns3::Ptr<ns3::Node>, unsigned char, unsigned char, unsigned char)'
/usr/bin/ld: ~/ns-3.40/contrib/opengym/examples/linear-mesh/sim.cc:901:(.text.startup+0x4d37): undefined reference to `ns3::AnimationInterface::UpdateNodeDescription(ns3::Ptr<ns3::Node>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: ~/ns-3.40/contrib/opengym/examples/linear-mesh/sim.cc:902:(.text.startup+0x4d7a): undefined reference to `ns3::AnimationInterface::UpdateNodeColor(ns3::Ptr<ns3::Node>, unsigned char, unsigned char, unsigned char)'
/usr/bin/ld: ~/ns-3.40/contrib/opengym/examples/linear-mesh/sim.cc:913:(.text.startup+0x4df2): undefined reference to `ns3::AnimationInterface::~AnimationInterface()'
头文件和声明:
#include "ns3/netanim-module.h"
AnimationInterface anim("complex-bridge.xml");
事实上之前scratch里面跑的cc从来没有这种问题,以上内容就足够
排错
报错是“/usr/bin/ld”报错,所以是链接问题,所以大概是没有库,所以去看CMakelists:
build_lib_example(
NAME linear-mesh
SOURCE_FILES linear-mesh/sim.cc
LIBRARIES_TO_LINK
${libapplications}
${libcore}
${libinternet}
${libopengym}
${libwifi}
)
查看anim有关CMakelists:
build_lib_example(
NAME wireless-animation
SOURCE_FILES wireless-animation.cc
LIBRARIES_TO_LINK
${libnetanim}
${libapplications}
${libpoint-to-point}
${libcsma}
${libwifi}
${libmobility}
${libnetwork}
)
缺少 ${libnetanim},加上就好了。
更多推荐
所有评论(0)