Home > other >  ROS compile-time tip ROS: : init () and so on ROS library function undefined reference, however CMak
ROS compile-time tip ROS: : init () and so on ROS library function undefined reference, however CMak

Time:10-10

Recently in the use of ROBOTIS Thormang3 simulator, you can compile a successful project, suddenly in a compiler error:
CMakeFiles/hello_world. Dir/SRC/hello_world. CPP. O: : in the function 'main'

The hello_world. CPP: (. Text + 0 x61) : "ros: : init (int& , char * *, STD: : string const& , unsigned int) 'undefined reference

The hello_world. CPP: (. Text + 0 XBD) : "ros: : NodeHandle: : NodeHandle (STD: : string const& , STD: : map, STD: : allocator & gt;> Const&) Undefined reference to '
.
.

.

CMakeFiles/hello_world. Dir/SRC/hello_world. CPP. O: : in the function 'main'

The hello_world. CPP: (. Text + 0 x61) : "ros: : init (int& , char * *, STD: : string const& , unsigned int) 'undefined reference

The hello_world. CPP: (. Text + 0 XBD) : "ros: : NodeHandle: : NodeHandle (STD: : string const& , STD: : map, STD: : allocator & gt;> Const&) Undefined reference to '


Supposedly CMakeList. TXT without correct reference roscpp, view the corresponding CMakeList CPP. TXT is as follows:


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# CMake
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Cmake_minimum_required (VERSION 2.8.3)
Project (thormang3_gazebo)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Packages
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Find_package (catkin REQUIRED COMPONENTS
Roscpp
Std_msgs
)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Declare ROS messages, services and actions
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Declare ROS dynamic reconfigure the parameters
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Catkin specific configuration
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Catkin_package (
CATKIN_DEPENDS
Roscpp
Std_msgs
)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Build
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Include_directories (
The ${catkin_INCLUDE_DIRS}
)

Add_executable (gazebo_grip_pub
SRC/gazebo_grip_pub. CPP
)

Target_link_libraries (gazebo_grip_pub
The ${catkin_LIBRARIES}
)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Install
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Install the TARGETS gazebo_grip_pub
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
The RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

Install DIRECTORY config
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

Install DIRECTORY launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

Install DIRECTORY worlds
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Test
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


Seen from the above should have correct reference roscpp, and add_executable () also behind the various reference function order no problem, very puzzling problem in where? Seek help from a great god!

CodePudding user response:

I compiled in ROS helloworld also encounter the same problem, as long as the reference ROS function will prompt "undefined reference", when the annotation to the main function of ROS function to compile, there is no mistake, CMakeLists. TXT, package. The XML, the source environment variable, check n times, with strives for the great god help!

CodePudding user response:

Find the solution to the problem, to build the workspace and package, perfect solution!
  • Related