Ask Your Question

error: "invoking make failed"

asked 2013-07-15 23:11:46 -0500

albarranco gravatar image

updated 2013-07-17 00:17:50 -0500

hello, when I run catkin_make I get the following errors:

Scanning dependencies of target gira
[100%] Building CXX object prueba/CMakeFiles/gira.dir/src/gira.cpp.o
Linking CXX executable /home/turtlebot/catkin_ws/devel/lib/proyecto/gira
CMakeFiles/gira.dir/src/gira.cpp.o: In function `main':
gira.cpp:(.text+0x55): undefined reference to `ros::init(int&, char**, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'
gira.cpp:(.text+0xa5): undefined reference to `ros::NodeHandle::NodeHandle...

any idea what could be the mistake? thanks

the executable gira.cpp:

#include "ros/ros.h"   
#include "geometry_msgs/Twist.h"  

int main(int argc, char **argv)

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

    ros::NodeHandle n;

    ros::Publisher vel_pub_=n.advertise<geometry_msgs::Twist>("cmd_vel", 1);   

    geometry_msgs::Twist vel;

    ros::Rate loop_rate(10);   

    while (ros::ok())   
        vel.linear.x = 0.1;   //velocidad de avance
        vel.angular.z = 0.3;   //velocidad de giro



    return 0;

the CMakeLists.txt (catkin specific configuration and built) :

cmake_minimum_required(VERSION 2.8.3) project(prueba)

find_package(catkin REQUIRED COMPONENTS geometry_msgs image_transport nav_msgs roscpp sensor_msgs std_msgs )

catkin_package( INCLUDE_DIRS include # LIBRARIES prueba # CATKIN_DEPENDS geometry_msgs image_transport nav_msgs roscpp sensor_msgs std_msgs turtlebot_node # DEPENDS system_lib ) ## Specify additional locations of header files ## Your package locations should be listed before other locations include_directories(include ${catkin_INCLUDE_DIRS} )

## Declare a cpp library # add_library(prueba # src/${PROJECT_NAME}/prueba.cpp # )

## Declare a cpp executable # add_executable(prueba_node src/prueba_node.cpp) add_executable(gira src/gira.cpp)

## Add cmake target dependencies of the executable/library ## as an example, message headers may need to be generated before nodes # add_dependencies(prueba_node prueba_generate_messages_cpp)

## Specify libraries to link a library or executable target against # target_link_libraries(prueba_node # ${catkin_LIBRARIES} # )

edit retag flag offensive close merge delete


It seems that the problem is with your code. Without the code, its quite hard to figure out the solution to this problem

Asfandyar Ashraf Malik gravatar image Asfandyar Ashraf Malik  ( 2013-07-15 23:24:28 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-07-15 23:57:45 -0500

ipso gravatar image

Undefined references indicate linker problems. It seems like the linker cannot find any ROS related symbols. Are you sure you have your package.xml and CMakeLists.txt setup properly?

edit flag offensive delete link more


I've only added to CMakeLists.txt add_executable(gira src/gira.cpp). Do I have to change something else in the CMakeLists.txt or package.xml?

albarranco gravatar image albarranco  ( 2013-07-16 00:47:40 -0500 )edit

Then please post the contents of your CMakeLists.txt (add it to your original question).

ipso gravatar image ipso  ( 2013-07-16 21:42:20 -0500 )edit

Solved, I forgot to add target_link_libraries (gira $ {catkin_LIBRARIES}) to CMakeList.txt. Thanks

albarranco gravatar image albarranco  ( 2013-10-18 05:49:15 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-07-15 23:11:46 -0500

Seen: 1,638 times

Last updated: Jul 17 '13