Compile error ros kinetic ubuntu 16.04
Hi there, i am using ros kinetic on ubuntu 16.04. I simply tried to compile talker listener example of the ros tutorial and always receive the follow compiler/linker error:
CMakeFiles/talker.dir/src/talker.cpp.o: In function `main':
talker.cpp:(.text+0x70): undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
talker.cpp:(.text+0xcc): undefined reference to `ros::NodeHandle::NodeHandle(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'
talker.cpp:(.text+0x29a): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
CMakeFiles/talker.dir/src/talker.cpp.o: In function `void ros::Publisher::publish<std_msgs::String_<std::allocator<void> > >(std_msgs::String_<std::allocator<void> > const&) const':
talker.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_]+0xa0): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
talker.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_]+0x1a3): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
talker.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_]+0x29e): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
talker.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_]+0x3c1): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
CMakeFiles/talker.dir/src/talker.cpp.o:talker.cpp:(.text._ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_[_ZNK3ros9Publisher7publishIN8std_msgs7String_ISaIvEEEEEvRKT_]+0x4c4): more undefined references to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)' follow
collect2: error: ld returned 1 exit status
trajectoryplanning/CMakeFiles/talker.dir/build.make:113: recipe for target '/home/graf/catkin_ws/devel/lib/trajectoryplanning/talker' failed
make[2]: *** [/home/graf/catkin_ws/devel/lib/trajectoryplanning/talker] Error 1
CMakeFiles/Makefile2:526: recipe for target 'trajectoryplanning/CMakeFiles/talker.dir/all' failed
make[1]: *** [trajectoryplanning/CMakeFiles/talker.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/listener.dir/src/listener.cpp.o: In function `chatterCallback(boost::shared_ptr<std_msgs::String_<std::allocator<void> > const> const&)':
listener.cpp:(.text+0x78): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
CMakeFiles/listener.dir/src/listener.cpp.o: In function `main':
listener.cpp:(.text+0x1dc): undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
listener.cpp:(.text+0x238): undefined reference to `ros::NodeHandle::NodeHandle(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&)'
CMakeFiles/listener.dir/src/listener.cpp.o: In function `ros::SubscriptionCallbackHelperT<boost::shared_ptr<std_msgs::String_<std::allocator<void> > const> const&, void>::deserialize(ros::SubscriptionCallbackHelperDeserializeParams const&)':
listener.cpp:(.text._ZN3ros27SubscriptionCallbackHelperTIRKN5boost10shared_ptrIKN8std_msgs7String_ISaIvEEEEEvE11deserializeERKNS_43SubscriptionCallbackHelperDeserializeParamsE[_ZN3ros27SubscriptionCallbackHelperTIRKN5boost10shared_ptrIKN8std_msgs7String_ISaIvEEEEEvE11deserializeERKNS_43SubscriptionCallbackHelperDeserializeParamsE]+0xba): undefined reference to `ros::console::initializeLogLocation(ros::console::LogLocation*, std::string const&, ros::console::levels::Level)'
collect2: error: ld returned 1 exit status
trajectoryplanning/CMakeFiles/listener.dir/build.make:113: recipe for target '/home/graf/catkin_ws/devel/lib/trajectoryplanning/listener' failed
make[2]: *** [/home/graf/catkin_ws/devel/lib/trajectoryplanning/listener] Error 1
CMakeFiles/Makefile2 ...
This is a linker problem you're having here. Can you add your CMakeLists.txt file as well. Then we should be able to work out what the problem is.