ROS中编译通过但是遇到可执行文件找不到的问题


网上搜索发现别人说是CMakeLists中catkin_package() 没有声明的问题,没有在/home/mgody/catkin_ws/devel/lib/package/下生成可执行文件,可是自己已经声明了的。

自己的CMakeLists中是这样的:

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


find_package(catkin REQUIRED COMPONENTS
 XXX
)
add_executable(
XXX
)
target_link_libraries(
XXX
${catkin_LIBRARIES}
)
catkin_package(
  CATKIN_DEPENDS
 XXX
  ${CATKIN_DEPS} ${ROSDEP_DEPS}
)
include_directories(
   include
  ${catkin_INCLUDE_DIRS}
)

反复查找问题,发现是CMakeLists 中的声明顺序有问题,要先声明catkin_package(),再声明add_executable()改成这样就好了:
cmake_minimum_required(VERSION 2.8.3)
project(XXX)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11")

find_package(catkin REQUIRED COMPONENTS
 XXX
)
catkin_package(
  CATKIN_DEPENDS
 XXX
  ${CATKIN_DEPS} ${ROSDEP_DEPS}
)
include_directories(
   include
  ${catkin_INCLUDE_DIRS}
)
add_executable(
XXX
)
target_link_libraries(
XXX
${catkin_LIBRARIES}
)

你可能感兴趣的:(ROS)