Ask Your Question
1

catkin_make recipe for target ' ' failed

asked 2018-06-20 09:03:11 -0600

Kaaaaaai gravatar image

updated 2018-06-20 09:21:24 -0600

I cannot run catkin_make command on ubuntu 16.04 and the output is as followed.

student@IAR-IPR-C1035:~/slamdog/catkin_ws$ catkin_make
Base path: /home/student/slamdog/catkin_ws
Source space: /home/student/slamdog/catkin_ws/src
Build space: /home/student/slamdog/catkin_ws/build
Devel space: /home/student/slamdog/catkin_ws/devel
Install space: /home/student/slamdog/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/student/slamdog/catkin_ws/build"
####
####
#### Running command: "make -j4 -l4" in "/home/student/slamdog/catkin_ws/build"
####
[  0%] Built target actionlib_msgs_generate_messages_lisp
[  0%] Built target geometry_msgs_generate_messages_py
[  0%] Built target tf2_msgs_generate_messages_nodejs
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target actionlib_msgs_generate_messages_eus
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target actionlib_msgs_generate_messages_nodejs
[  0%] Built target geometry_msgs_generate_messages_cpp
[  0%] Built target geometry_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_nodejs
[  0%] Built target geometry_msgs_generate_messages_nodejs
[  0%] Built target actionlib_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target tf2_msgs_generate_messages_cpp
[  0%] Built target tf2_msgs_generate_messages_py
[  0%] Built target tf2_msgs_generate_messages_eus
[  0%] Built target geometry_msgs_generate_messages_eus
[  0%] Built target tf2_msgs_generate_messages_lisp
[  0%] Built target actionlib_msgs_generate_messages_py
[  0%] Built target _slamdog_core_generate_messages_check_deps_SensorData
[ 16%] Built target slamdog_utils
[ 25%] Built target slamdog_core_generate_messages_nodejs
[ 41%] Built target slamdog_core_generate_messages_py
[ 50%] Built target slamdog_core_generate_messages_lisp
[ 66%] Built target slamdog_core_generate_messages_eus
[ 75%] Built target slamdog_core_generate_messages_cpp
[ 75%] Built target slamdog_core_generate_messages
[ 83%] Linking CXX executable /home/student/slamdog/catkin_ws/devel/lib/slamdog_core/slamdog_core
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
slamdog_core/CMakeFiles/slamdog_core.dir/build.make:141: recipe for target '/home/student/slamdog/catkin_ws/devel/lib/slamdog_core/slamdog_core' failed
make[2]: *** [/home/student/slamdog/catkin_ws/devel/lib/slamdog_core/slamdog_core] Error 1
CMakeFiles/Makefile2:1095: recipe for target 'slamdog_core/CMakeFiles/slamdog_core.dir/all' failed
make[1]: *** [slamdog_core/CMakeFiles/slamdog_core.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

And my CMakeList is as followed.

cmake_minimum_required(VERSION 2.8.3)
project(slamdog)
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

## Add support for C++11, supporpigpioted in ROS Kinetic and newer
add_definitions(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  genmsg
  message_generation
  geometry_msgs
  sensor_msgs
  slamdog_utils
)

## Generate messages in the 'msg' folder
add_message_files(
  FILES
  SensorData.msg
)

## Generate added messages and services with any dependencies listed here
generate_messages(
  DEPENDENCIES
  std_msgs
  geometry_msgs
)

site_name(HOSTNAME)
set(REPO "/home/student/slamdog")
if (${HOSTNAME} STREQUAL "bal-thinkpad")
  set(REPO "/home/bal/Projects/kit/slamdog")
elseif (${HOSTNAME} STREQUAL "iar-ipr-c1146")
  set(REPO "/home/heilig/slamdog_project/slamdog")
endif()

## Specify additional locations of header files
## Your package locations should be listed before other locations

include_directories(
  include
  ${REPO}/slamdog_core/include
  ${catkin_INCLUDE_DIRS}
  )

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure

## Declare a C++ executable
add_executable(slamdog_core src/SensorPublisher.cpp src/OdomPublisher.cpp)

## Add cmake target dependencies of the executable
target_link_libraries(slamdog_core ${catkin_LIBRARIES}) ##deleted ${SLAMDOG_HW_LIBRARY}

add_dependencies(slamdog_core ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGET}  ${PROJECT_NAME}_msgs_generate_messages_cpp)

What should I do to fix this problem? Thanks a lot!

edit retag flag offensive close merge delete

Comments

I believe the compiler is not finding a reference to main() anywhere. https://stackoverflow.com/questions/2...

what does slamdog_core look like?

Waterluvian gravatar imageWaterluvian ( 2018-06-20 09:19:32 -0600 )edit

Thanks for your answer and I think the problem is the main().

Kaaaaaai gravatar imageKaaaaaai ( 2018-06-20 10:08:13 -0600 )edit

slamdog_core is a package under catkin_ws/src as followed:

slamdog_core - include - slamdog_core - OdomPublisher.hpp - SensorPublisher.hpp - msg - SensorData.msg - src - OdomPublisher.cpp - SensorPublisher.cpp

Kaaaaaai gravatar imageKaaaaaai ( 2018-06-20 10:12:22 -0600 )edit

I just want to make my target clearly so I named it as slamdog_core

Kaaaaaai gravatar imageKaaaaaai ( 2018-06-20 10:12:56 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-06-20 09:30:59 -0600

sloretz gravatar image

The text in your title catkin_make recipe for target ' ' failed means the build failed. Look a few lines higher to see why.

[ 83%] Linking CXX executable /home/student/slamdog/catkin_ws/devel/lib/slamdog_core/slamdog_core
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
slamdog_core/CMakeFiles/slamdog_core.dir/build.make:141: recipe for target '/home/student/slamdog/catkin_ws/devel/lib/slamdog_core/slamdog_core' failed

Neither of the files SensorPublisher.cpp or OdomPublisher.cpp contain an int main() {...} function. Is there another source file containing main()? If there is no main() because the goal is to create a library then use add_library() instead of add_executable().

edit flag offensive delete link more

Comments

Thanks for your answer! I've run catkin_make correctly by changing add_executable() to add_library().

Kaaaaaai gravatar imageKaaaaaai ( 2018-06-20 09:57:18 -0600 )edit

My goal is to let PC monitor the slamdog's sensors, which is controlled remotely by Raspberry, although catkin_make command has no problem, I still cannot get the message class for type slamdog_core/SensorData . So do you think this part is ok or I have problem in other skripts?

Kaaaaaai gravatar imageKaaaaaai ( 2018-06-20 09:59:10 -0600 )edit

Sounds like https://answers.ros.org/question/1889...

I see ${PROJECT_NAME}_msgs_generate_messages_cpp, in add_dependencies(). I think the right target name might be ${PROJECT_NAME}_generate_messages_cpp instead.

sloretz gravatar imagesloretz ( 2018-06-20 10:07:53 -0600 )edit

Thanks for your sharing! I've tried this but it still doesn't work. I believe I should use add_executable() and add some other source files which contain an int main() {...}. But it might be much more complex because if I used other sources I need to add more #include of other packages

Kaaaaaai gravatar imageKaaaaaai ( 2018-06-20 11:00:45 -0600 )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

1 follower

Stats

Asked: 2018-06-20 09:03:11 -0600

Seen: 3,393 times

Last updated: Jun 20 '18