qq_40586691 2024-06-25 22:16 采纳率: 0%
浏览 36

CMake Error:Could not find 'share/std_msgs/cmake/std_msgs-msg-paths.cmake'


CMake Error at /opt/ros/melodic/share/genmsg/cmake/genmsg-extras.cmake:271 (message):
  Could not find 'share/std_msgs/cmake/std_msgs-msg-paths.cmake' (searched in
  '/home/mandy/ross/leg_tracker_ws/devel')

img

错误日志如下: /home/mandy/ross/leg_tracker_ws/build/CMakeFiles/CMakeError.log

(py36sarl) mandy@LAPTOP-U3AQMP8F:~/ross/leg_tracker_ws$ cat /home/mandy/ross/leg_tracker_ws/build/CMakeFiles/CMakeError.log
Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/mandy/ross/leg_tracker_ws/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_65fba/fast && /usr/bin/make  -f CMakeFiles/cmTC_65fba.dir/build.make CMakeFiles/cmTC_65fba.dir/build
make[1]: Entering directory '/home/mandy/ross/leg_tracker_ws/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_65fba.dir/src.c.o
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_65fba.dir/src.c.o -c /home/mandy/ross/leg_tracker_ws/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_65fba
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_65fba.dir/link.txt --verbose=1
/usr/bin/cc -rdynamic CMakeFiles/cmTC_65fba.dir/src.c.o -o cmTC_65fba
CMakeFiles/cmTC_65fba.dir/src.c.o: In function `main':
src.c:(.text+0x3e): undefined reference to `pthread_create'
src.c:(.text+0x4a): undefined reference to `pthread_detach'
src.c:(.text+0x56): undefined reference to `pthread_cancel'
src.c:(.text+0x67): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_65fba.dir/build.make:98: recipe for target 'cmTC_65fba' failed
make[1]: *** [cmTC_65fba] Error 1
make[1]: Leaving directory '/home/mandy/ross/leg_tracker_ws/build/CMakeFiles/CMakeTmp'
Makefile:127: recipe for target 'cmTC_65fba/fast' failed
make: *** [cmTC_65fba/fast] Error 2


Source file was:
#include <pthread.h>

static void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/mandy/ross/leg_tracker_ws/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_8c165/fast && /usr/bin/make  -f CMakeFiles/cmTC_8c165.dir/build.make CMakeFiles/cmTC_8c165.dir/build
make[1]: Entering directory '/home/mandy/ross/leg_tracker_ws/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_8c165.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_8c165.dir/CheckFunctionExists.c.o -c /usr/local/share/cmake-3.21/Modules/CheckFunctionExists.c
Linking C executable cmTC_8c165
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8c165.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_8c165.dir/CheckFunctionExists.c.o -o cmTC_8c165  -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_8c165.dir/build.make:98: recipe for target 'cmTC_8c165' failed
make[1]: *** [cmTC_8c165] Error 1
make[1]: Leaving directory '/home/mandy/ross/leg_tracker_ws/build/CMakeFiles/CMakeTmp'
Makefile:127: recipe for target 'cmTC_8c165/fast' failed
make: *** [cmTC_8c165/fast] Error 2


  • 写回答

1条回答 默认 最新

  • 阿里嘎多学长 2024-06-25 22:39
    关注

    以下内容由CHATGPT及阿里嘎多学长共同生成、有用望采纳:


    遇到CMake配置错误和编译问题时,通常需要分步骤来解决。以下是一些可能的解决方案:

    1. 更新CMake版本

      • 错误提示中提到CMake版本需要更新,建议升级到至少2.8.12版本或更高。你可以使用包管理器来更新CMake,例如在Ubuntu上可以使用sudo apt-get install cmake
    2. 解决找不到std_msgs-msg-paths.cmake的问题

      • 这通常意味着CMake无法找到ROS(Robot Operating System)的消息生成路径。确保你的ROS环境设置正确,包括.bashrc文件中的source /opt/ros/melodic/setup.bash
      • 如果你使用的是catkin工具,确保catkin_make命令在正确的工作空间中执行。
    3. 解决链接错误

      • 错误提示undefined reference to 'pthread_create'等函数,这表明编译器在链接时找不到pthread库。这可能是因为你的系统没有安装libpthread库,或者CMake没有正确找到它。
      • 你可以尝试安装libpthread库,例如在Ubuntu上使用sudo apt-get install libpthread-stubs0-dev
    4. 解决编译错误

      • 错误提示cannot find -lpthreads,这表明链接器无法找到pthreads库。这可能是因为你的系统使用的是NPTL(Native POSIX Thread Library),而不是旧的POSIX线程库,它不需要单独链接-lpthreads
      • 你可以尝试在CMakeLists.txt中移除或修改与-lpthreads相关的链接指令。
    5. 检查CMakeLists.txt

      • 检查CMakeLists.txt文件,确保所有的依赖项和消息生成指令都是正确的。如果有必要,可以对比ROS的官方教程或示例项目来调整你的CMakeLists.txt。
    6. 清理和重新构建

      • 在解决了上述问题后,运行catkin clean来清理构建目录,然后重新运行catkin_make
    7. 参考链接

    如果上述步骤无法解决问题,你可以提供更多的信息,或者考虑在ROS社区论坛或相关的技术社区发帖求助。

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 6月25日

悬赏问题

  • ¥15 x264库中预测模式字IPM、运动向量差MVD、量化后的DCT系数的位置
  • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused
  • ¥20 关于web前端如何播放二次加密m3u8视频的问题
  • ¥15 使用百度地图api 位置函数报错?
  • ¥15 metamask如何添加TRON自定义网络
  • ¥66 关于川崎机器人调速问题
  • ¥15 winFrom界面无法打开
  • ¥30 crossover21 ARM64版本安装软件问题
  • ¥15 mymetaobjecthandler没有进入
  • ¥15 mmo能不能做客户端怪物