ROSTopics example build error

user:~/catkin_ws$ catkin_make --only-pkg-with-deps topic_publisher_pkg

here error is occured.

Scanning dependencies of target topic_publisher_pkg
[ 50%] Building CXX object topic_publisher_pkg/CMakeFiles/topic_publisher_pkg.dir/src/simple_topic_publisher.cpp.o
[ 75%] Linking CXX executable /home/user/catkin_ws/devel/lib/topic_publisher_pkg/topic_publisher_pkg_node
/usr/bin/ld: CMakeFiles/topic_publisher_pkg_node.dir/src/simple_topic_publisher.cpp.o: in function `main':
simple_topic_publisher.cpp:(.text+0x95): undefined reference to `ros::init(int&, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text+0x127): undefined reference to `ros::NodeHandle::NodeHandle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text+0x1d2): undefined reference to `ros::Rate::Rate(double)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text+0x1f0): undefined reference to `ros::ok()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text+0x212): undefined reference to `ros::spinOnce()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text+0x221): undefined reference to `ros::Rate::sleep()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text+0x246): undefined reference to `ros::Publisher::~Publisher()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text+0x255): undefined reference to `ros::NodeHandle::~NodeHandle()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text+0x31e): undefined reference to `ros::Publisher::~Publisher()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text+0x32d): undefined reference to `ros::NodeHandle::~NodeHandle()'
/usr/bin/ld: CMakeFiles/topic_publisher_pkg_node.dir/src/simple_topic_publisher.cpp.o: in function `ros::Publisher ros::NodeHandle::advertise<std_msgs::Int32_<std::allocator<void> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, bool)':
simple_topic_publisher.cpp:(.text._ZN3ros10NodeHandle9advertiseIN8std_msgs6Int32_ISaIvEEEEENS_9PublisherERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjb[_ZN3ros10NodeHandle9advertiseIN8std_msgs6Int32_ISaIvEEEEENS_9PublisherERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjb]+0x139): undefined reference to `ros::NodeHandle::advertise(ros::AdvertiseOptions&)'
/usr/bin/ld: CMakeFiles/topic_publisher_pkg_node.dir/src/simple_topic_publisher.cpp.o: in function `void ros::Publisher::publish<std_msgs::Int32_<std::allocator<void> > >(std_msgs::Int32_<std::allocator<void> > const&) const':
simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x4b): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x5b): undefined reference to `ros::console::initialize()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xae): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xee): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xfa): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x160): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x16b): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x17b): undefined reference to `ros::console::initialize()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x1ce): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x20e): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x21a): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x272): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x27d): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x28d): undefined reference to `ros::console::initialize()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x2e0): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x320): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x32c): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x384): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x3a5): undefined reference to `ros::Publisher::Impl::isValid() const'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x3b7): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x3c7): undefined reference to `ros::console::initialize()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x41a): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x45a): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x466): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x4cc): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x4d7): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x4e7): undefined reference to `ros::console::initialize()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x53a): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x57a): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x586): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x5f5): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x600): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x610): undefined reference to `ros::console::initialize()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x663): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x6a3): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x6af): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x707): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x81e): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x82e): undefined reference to `ros::console::initialize()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x881): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x8c1): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x8cd): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x933): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x93e): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x94e): undefined reference to `ros::console::initialize()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x9a1): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x9e1): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0x9ed): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xaaf): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xaba): undefined reference to `ros::console::g_initialized'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xaca): undefined reference to `ros::console::initialize()'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xb1d): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xb5d): undefined reference to `ros::console::setLogLocationLevel(ros::console::LogLocation*, ros::console::levels::Level)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xb69): undefined reference to `ros::console::checkLogLocationEnabled(ros::console::LogLocation*)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xbc1): undefined reference to `ros::console::print(ros::console::FilterBase*, void*, ros::console::levels::Level, char const*, int, char const*, char const*, ...)'
/usr/bin/ld: simple_topic_publisher.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs6Int32_ISaIvEEEEEvRKT_]+0xc55): undefined reference to `ros::Publisher::publish(boost::function<ros::SerializedMessage ()> const&, ros::SerializedMessage&) const'
/usr/bin/ld: CMakeFiles/topic_publisher_pkg_node.dir/src/simple_topic_publisher.cpp.o: in function `void ros::serialization::Serializer<unsigned int>::write<ros::serialization::OStream>(ros::serialization::OStream&, unsigned int)':
simple_topic_publisher.cpp:(.text._ZN3ros13serialization10SerializerIjE5writeINS0_7OStreamEEEvRT_j[_ZN3ros13serialization10SerializerIjE5writeINS0_7OStreamEEEvRT_j]+0x56): undefined reference to `ros::serialization::throwStreamOverrun()'
/usr/bin/ld: CMakeFiles/topic_publisher_pkg_node.dir/src/simple_topic_publisher.cpp.o: in function `void ros::serialization::Serializer<int>::write<ros::serialization::OStream>(ros::serialization::OStream&, int)':
simple_topic_publisher.cpp:(.text._ZN3ros13serialization10SerializerIiE5writeINS0_7OStreamEEEvRT_i[_ZN3ros13serialization10SerializerIiE5writeINS0_7OStreamEEEvRT_i]+0x56): undefined reference to `ros::serialization::throwStreamOverrun()'
collect2: error: ld returned 1 exit status
make[2]: *** [topic_publisher_pkg/CMakeFiles/topic_publisher_pkg_node.dir/build.make:84: /home/user/catkin_ws/devel/lib/topic_publisher_pkg/topic_publisher_pkg_node] Error 1
make[1]: *** [CMakeFiles/Makefile2:420: topic_publisher_pkg/CMakeFiles/topic_publisher_pkg_node.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[100%] Linking CXX shared library /home/user/catkin_ws/devel/lib/libtopic_publisher_pkg.so
[100%] Built target topic_publisher_pkg
make: *** [Makefile:141: all] Error 2
Invoking "make -j8 -l8" failed

Hi,

It looks like there is a problem with the node file simple_topic_publisher.cpp.

This might have been a mistake while copying the code from the instructions.

Please double check it. Once you do that, you can clean your workspace for a sanity check and compiling again:

cd ~/catkin_ws
rm -rf build/ devel/
catkin_make --only-pkg-with-deps topic_publisher_pkg
source devel/setup.bash
rospack profile

If you keep having the error, please provide more context to your issues. For example, in this case, the content of the mentioned file would be helpful.

Hi

Thank you for reply.
I’ve just copied and pasted the all example codes, so I don’t know what I miss.

catkin_make --only-pkg-with-deps topic_publisher_pkg 

I followed your commands, but catkin_make has errors.
I attached all file which I did at the terminal and error codes.
please check this.

Thank you.


From all your have shared, I still can’t see what’s wrong. SO, please don’t just copy code; understand whatever you are copying so that you will be able to learn and solve problems down the line.

There could be genuine typos or misses in the code, or perhaps you also left some things out.

This part of the error provides some hints:

simple_topic_publisher.cpp:(.text+0x95): undefined reference to `ros::init(int&, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'

The error is happening at this point:

  • Was roscpp included as a dependency when creating the package?
  • Was ros included (imported) in this file?
1 Like

I solved this issue.
thank you

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.