ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Lizhuo's profile - activity

2017-02-01 17:16:28 -0500 received badge  Famous Question (source)
2016-08-10 22:05:15 -0500 commented question Undefined reference to ros::init on Jade

Just follow the tutorial. The problem is discovered, that the version of GCC is changed from 4.9 to 5. When I switch the version back to 4.9, It works! @alecive

2016-08-10 22:01:31 -0500 commented answer Undefined reference to ros::init on Jade

should I close this problem?

2016-08-10 22:01:08 -0500 commented answer Undefined reference to ros::init on Jade

Thanks! My problem has solved. First, I switch the GCC version back to 4.9. Then run CATKIN_MAKE CLEAN to clean the build file. And when I run CATKIN_MAKE this time, it is OK! Thank you @ahendrix !

2016-08-10 21:52:11 -0500 received badge  Scholar (source)
2016-08-10 21:52:08 -0500 received badge  Supporter (source)
2016-08-10 10:59:04 -0500 received badge  Editor (source)
2016-08-10 10:41:53 -0500 received badge  Notable Question (source)
2016-08-10 05:09:32 -0500 commented answer Undefined reference to ros::init on Jade

Yes. I have switched. But I try to change GCC version back to 4.9, it also doesn't work. @ahendrix

2016-08-09 21:50:55 -0500 commented answer Undefined reference to ros::init on Jade

my operating system is Ubuntu 15.04 and my GCC version is 5. Could you tell me how to disable C++11? Thank you~@ahendrix

2016-08-09 21:24:48 -0500 received badge  Popular Question (source)
2016-08-09 10:55:08 -0500 commented question Undefined reference to ros::init on Jade

I have try it. But it doesn't work. @Ifr

2016-08-09 04:34:04 -0500 asked a question Undefined reference

I'm a freshman on ROS. And recently I come up with a problem when I learn the Tutorials(WritingPublisherSubscriber(c++)).

When I add the talker.cpp to the project, It appear I have problem with Undefined reference

Here is my talker.cpp

#include "ros/ros.h"
#include "std_msgs/String.h"

#include <sstream>


int main(int argc, char **argv)
{

   ros::init(argc, argv, "talker");


   return 0;
}

The CMakeLists.txt file has following content

cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)

## Find catkin and any catkin packages
find_package(catkin REQUIRED COMPONENTS 
roscpp 
rospy 
std_msgs 
message_generation)

## Declare ROS messages and services
add_message_files(FILES Num.msg)
add_service_files(FILES AddTwoInts.srv)

## Generate added messages and services
generate_messages(DEPENDENCIES std_msgs)

## Declare a catkin package
catkin_package()

## Build talker and listener
include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
add_dependencies(talker beginner_tutorials_generate_messages_cpp)

and Package.xml is here

<?xml version="1.0"?>
<package>
 <name>beginner_tutorials</name>
   <version>0.0.0</version>
 <description>The beginner_tutorials package</description>


  <maintainer email="lizhuo@todo.todo">lizhuo</maintainer>
  <license>TODO</license>

  <buildtool_depend>catkin</buildtool_depend>

  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>message_generation</build_depend>
  <run_depend>message_runtime</run_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>


</package>

While compiling the above code using catkin_make, the error is

Linking CXX executable /home/lizhuo/catkin_lz/devel/lib/beginner_tutorials/talker
CMakeFiles/talker.dir/src/talker.cpp.o:in function ‘main’:
talker.cpp:(.text+0x55):对‘ros::init(int&, char**, std::__cxx11::basic_string<char, std::char_traits<char>,       std::allocator<char> > const&, unsigned int)’未定义的引用(it means Undefined reference)
collect2: error: ld returned 1 exit status

I look though many answers, but cannot solve my problem. So I really need help. Thanks!

2016-08-09 04:34:04 -0500 asked a question Undefined reference to ros::init on Jade

I'm a freshman on ROS. And recently I come up with a problem when I learn the Tutorials(WritingPublisherSubscriber(c++)).

When I add the talker.cpp to the project, It appear I have problem with Undefined reference

Here is my talker.cpp

#include "ros/ros.h"
#include "std_msgs/String.h"

#include <sstream>


int main(int argc, char **argv)
{

   ros::init(argc, argv, "talker");


   return 0;
}

The CMakeLists.txt file has following content

cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)

## Find catkin and any catkin packages
find_package(catkin REQUIRED COMPONENTS 
roscpp 
rospy 
std_msgs 
message_generation)

## Declare ROS messages and services
add_message_files(FILES Num.msg)
add_service_files(FILES AddTwoInts.srv)

## Generate added messages and services
generate_messages(DEPENDENCIES std_msgs)

## Declare a catkin package
catkin_package()

## Build talker and listener
include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
add_dependencies(talker beginner_tutorials_generate_messages_cpp)

and Package.xml is here

<?xml version="1.0"?>
<package>
 <name>beginner_tutorials</name>
   <version>0.0.0</version>
 <description>The beginner_tutorials package</description>


  <maintainer email="lizhuo@todo.todo">lizhuo</maintainer>
  <license>TODO</license>

  <buildtool_depend>catkin</buildtool_depend>

  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>message_generation</build_depend>
  <run_depend>message_runtime</run_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>


</package>

While compiling the above code using catkin_make, the error is

Base path: /home/lizhuo/catkin_lz
Source space: /home/lizhuo/catkin_lz/src
Build space: /home/lizhuo/catkin_lz/build
Devel space: /home/lizhuo/catkin_lz/devel
Install space: /home/lizhuo/catkin_lz/install
####
#### Running command: "make cmake_check_build_system" in "/home/lizhuo/catkin_lz/build"
####
####
#### Running command: "make -j4 -l4" in "/home/lizhuo/catkin_lz/build"
####
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] [  0%] Built target _beginner_tutorials_generate_messages_check_deps_Num
Built target std_msgs_generate_messages_eus
[  0%] Built target _beginner_tutorials_generate_messages_check_deps_AddTwoInts
[ 33%] Built target beginner_tutorials_generate_messages_py
[ 50%] [ 66%] Built target beginner_tutorials_generate_messages_cpp
Built target beginner_tutorials_generate_messages_lisp
[ 91%] Built target beginner_tutorials_generate_messages_eus
[ 91%] Linking CXX executable ../devel/lib/beginner_tutorials/talker
Built target beginner_tutorials_generate_messages
CMakeFiles/talker.dir/src/talker.cpp.o:in the function ‘main’:
talker.cpp:(.text+0x55):对‘ros::init(int&, char**, std::__cxx11::basic_string<char, std::char_traits<char>,       std::allocator<char> > const&, unsigned int)’未定义的引用 (it means undefined reference)
collect2: error:ld return 1
beginner_tutorials/CMakeFiles/talker.dir/build.make:102: recipe for target  'devel/lib/beginner_tutorials/talker' failed
make[2]: *** [devel/lib/beginner_tutorials/talker] Error 1
CMakeFiles/Makefile2:1091: recipe for target 'beginner_tutorials/CMakeFiles/talker.dir/all' failed
make[1]: *** [beginner_tutorials/CMakeFiles/talker.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

I look though many answers, but cannot solve my problem. So I really need help. Thanks!