执行caktin_make时候,出现错误:CMake Error at /opt/ros/melodic/share/catkin/cmake/catkin_package.cmake:116
不知为何,忽然发现自己使用catkin_make编译空的功能包竟然也能报错,自己的操作为mkdir -p wu_ws/srccd work_wscatkin_make正常来讲,空的包是能直接编译通过的。但是竟然发生了如下错误。具体报错如下:CMake Error: File /home/wuxr/graspping/realsense_ws/src/package.xml does not exi
文章共1,470字 · 阅读需要大约5分钟
一键AI生成摘要,助你高效阅读
问答
·
不知为何,忽然发现自己使用catkin_make编译空的功能包竟然也能报错,
自己的操作为
mkdir -p wu_ws/src
cd work_ws
catkin_make
正常来讲,空的包是能直接编译通过的。但是竟然发生了如下错误。
具体报错如下:
CMake Error: File /home/wuxr/graspping/realsense_ws/src/package.xml does not exist.
CMake Error at /opt/ros/melodic/share/catkin/cmake/stamp.cmake:10 (configure_file):
configure_file Problem configuring file
Call Stack (most recent call first):
/opt/ros/melodic/share/catkin/cmake/catkin_package_xml.cmake:72 (stamp)
/opt/ros/melodic/share/catkin/cmake/catkin_package_xml.cmake:50 (_catkin_package_xml)
/opt/ros/melodic/share/catkin/cmake/catkin_package.cmake:99 (catkin_package_xml)
CMakeLists.txt:46 (catkin_package)
CMake Error at /opt/ros/melodic/share/catkin/cmake/catkin_package.cmake:116 (message):
catkin_package() 'catkin' must be listed as a buildtool dependency in the
package.xml
Call Stack (most recent call first):
/opt/ros/melodic/share/catkin/cmake/catkin_package.cmake:102 (_catkin_package)
CMakeLists.txt:46 (catkin_package)
-- Configuring incomplete, errors occurred!
See also "/home/wuxr/graspping/realsense_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/wuxr/graspping/realsense_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed
打开在src下面的CMakeLists.txt,因此仔细一看,好像和平常的CMakelists.txt文件不太一样,像是个软链接。于是运行ls -l后,发现真是,它指向了一个cmake。而且打开后,发现他是我之前做的一个ros包用到的CMakelist文件。所以报错了。。。。
(base) wuxr@wuxr:~/wu_ws/src$ ls -l
总用量 0
lrwxrwxrwx 1 wuxr wuxr 50 4月 16 20:25 CMakeLists.txt -> /opt/ros/melodic/share/catkin/cmake/toplevel.cmake
百度一番,有个哥们的解答有用。
将src下面的CMaklists.txt软链接删除,重新创建文件CMakeLists,复制以下代码到该文件。
# toplevel CMakeLists.txt for a catkin workspace
# catkin/cmake/toplevel.cmake
cmake_minimum_required(VERSION 2.8.3)
set(CATKIN_TOPLEVEL TRUE)
# search for catkin within the workspace
set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}")
execute_process(COMMAND ${_cmd}
RESULT_VARIABLE _res
OUTPUT_VARIABLE _out
ERROR_VARIABLE _err
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
if(NOT _res EQUAL 0 AND NOT _res EQUAL 2)
# searching fot catkin resulted in an error
string(REPLACE ";" " " _cmd_str "${_cmd}")
message(FATAL_ERROR "Search for 'catkin' in workspace failed (${_cmd_str}): ${_err}")
endif()
# include catkin from workspace or via find_package()
if(_res EQUAL 0)
set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/${_out}/cmake")
# include all.cmake without add_subdirectory to let it operate in same scope
include(${catkin_EXTRAS_DIR}/all.cmake NO_POLICY_SCOPE)
add_subdirectory("${_out}")
else()
# use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
# or CMAKE_PREFIX_PATH from the environment
if(NOT DEFINED CMAKE_PREFIX_PATH)
if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
endif()
endif()
# list of catkin workspaces
set(catkin_search_path "")
foreach(path ${CMAKE_PREFIX_PATH})
if(EXISTS "${path}/.catkin")
list(FIND catkin_search_path ${path} _index)
if(_index EQUAL -1)
list(APPEND catkin_search_path ${path})
endif()
endif()
endforeach()
# search for catkin in all workspaces
set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
find_package(catkin QUIET
NO_POLICY_SCOPE
PATHS ${catkin_search_path}
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
unset(CATKIN_TOPLEVEL_FIND_PACKAGE)
if(NOT catkin_FOUND)
message(FATAL_ERROR "find_package(catkin) failed. catkin was neither found in the workspace nor in the CMAKE_PREFIX_PATH. One reason may be that no ROS setup.sh was sourced before.")
endif()
endif()
catkin_workspace()
保存后,在cd wu_ws
回到工作空间,执行caktin_make
。成功编译。
更多推荐
已为社区贡献1条内容
所有评论(0)