0
$\begingroup$

Rosanswers logo

Hi everyone, I am having a little problem building a node. After I created and built the package, I sourced the setup.bash file. Then I added "src/camera.cpp" to the package. The CMakeList is:

cmake_minimum_required(VERSION 2.8.3)
project(chapter5_tutorials)

find_package(catkin REQUIRED
    COMPONENTS
      roscpp
      message_generation
      sensor_msgs
      dynamic_reconfigure
      driver_base
      cv_bridge
      image_transport
      camera_info_manager
      tf)

find_package(OpenCV REQUIRED)

generate_dynamic_reconfigure_options(
    cfg/Camera.cfg
    cfg/CameraStereo.cfg
    cfg/Homography.cfg)

catkin_package(
    CATKIN_DEPENDS
      roscpp
      message_runtime
      sensor_msgs
      dynamic_reconfigure
      driver_base
      cv_bridge
      image_transport
      camera_info_manager
      tf)

include_directories(${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})

add_executable(camera src/camera.cpp)
add_dependencies(camera ${PROJECT_NAME}_gencfg)
target_link_libraries(camera ${catkin_LIBRARIES})

add_executable(camera_timer src/camera_timer.cpp)
target_link_libraries(camera_timer ${catkin_LIBRARIES})

add_executable(camera_polling src/camera_polling.cpp)
target_link_libraries(camera_polling ${catkin_LIBRARIES})

add_executable(camera_stereo src/camera_stereo.cpp)
add_dependencies(camera_stereo ${PROJECT_NAME}_gencfg)
target_link_libraries(camera_stereo ${catkin_LIBRARIES})

add_executable(homography src/homography.cpp)
add_dependencies(homography ${PROJECT_NAME}_gencfg)
target_link_libraries(homography ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

install(TARGETS camera camera_timer camera_polling camera_stereo homography
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

foreach(dir bag config launch)
    install(DIRECTORY ${dir}/
        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/${dir})
endforeach(dir)

Then I use catkin_make again to build the package. The catkin_make output is:

Base path: /home/ally/dev/catkin_ws
Source space: /home/ally/dev/catkin_ws/src
Build space: /home/ally/dev/catkin_ws/build
Devel space: /home/ally/dev/catkin_ws/devel
Install space: /home/ally/dev/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/ally/dev/catkin_ws/build"
####
####
#### Running command: "make -j1 -l1" in "/home/ally/dev/catkin_ws/build"
####

The catkin_make did not add targets to camera.cpp. I cannot find executable inside the devel/lib/ and therefore cannot run the node. Where could go wrong? Please help me out. Thank you:)


Originally posted by Vivian Liu on ROS Answers with karma: 16 on 2016-02-17

Post score: 0


Original comments

Comment by gvdhoorn on 2016-02-17:
Can you please post your complete CMakeLists.txt (but without all the comments)? Please edit it into your original question.

Comment by mgruhler on 2016-02-17:
Also, please add the output of catkin_make.

Comment by gvdhoorn on 2016-02-17:
The CMakeLists.txt appears to be ok. To avoid transients, can you try to rebuild your workspace after a rm -rf build && rm -rf devel in your catkin_ws/ dir?

Comment by gvdhoorn on 2016-02-17:
Do any executables appear in devel/lib/? Can you show us your workspace layout and package structure?

Comment by Vivian Liu on 2016-02-17:
After removing build and devel folder, the catkin_make output is:

make: *** Did not identify target and cannot find makefile. Aborted.
Invoking "make -j1 -l1" failed

cannot find makefile?

Comment by gvdhoorn on 2016-02-17:
Please add your workspace layout to your question. I'm beginning to suspect you don't have the expected file & directory layout in your workspace and / or not invoking commands in the correct locations.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Well, it turned out that I have a wrong makefile inside the package folder. After removing it and rebuild the package again, the targets can be built. Thanks for the replies!!!


Originally posted by Vivian Liu with karma: 16 on 2016-02-17

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by gvdhoorn on 2016-02-17:
Please answer your own question by ticking the checkmark next to this answer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.