做一台安静的挖掘机 2021-12-23 16:31
浏览 390
已结题

编译ROS,class_loader编译失败,遇到src.cxx:(.text+0x48): undefined reference to `pthread_create'

执行从ros官网获取的编译命令:

./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release

报错如下,class_loader编译失败

<== Finished processing package [9 of 184]: 'cmake_modules'

==> Processing catkin package: 'class_loader'
==> Building with env: '/home/test/l00426222/ros_catkin_ws/install_isolated/env.sh'
==> cmake /home/test/l00426222/ros_catkin_ws/src/class_loader -DCATKIN_DEVEL_PREFIX=/home/test/l00426222/ros_catkin_ws/devel_isolated/class_loader -DCMAKE_INSTALL_PREFIX=/home/test/l00426222/ros_catkin_ws/install_isolated -DCMAKE_BUILD_TYPE=Release -G Unix Makefiles in '/home/test/l00426222/ros_catkin_ws/build_isolated/class_loader'
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find Boost (missing: Boost_INCLUDE_DIR thread system)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindBoost.cmake:2179 (find_package_handle_standard_args)
  CMakeLists.txt:12 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeOutput.log".
See also "/home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeError.log".
<== Failed to process package 'class_loader': 
  Command '['/home/test/l00426222/ros_catkin_ws/install_isolated/env.sh', 'cmake', '/home/test/l00426222/ros_catkin_ws/src/class_loader', '-DCATKIN_DEVEL_PREFIX=/home/test/l00426222/ros_catkin_ws/devel_isolated/class_loader', '-DCMAKE_INSTALL_PREFIX=/home/test/l00426222/ros_catkin_ws/install_isolated', '-DCMAKE_BUILD_TYPE=Release', '-G', 'Unix Makefiles']' returned non-zero exit status 1.

Reproduce this error by running:
==> cd /home/test/l00426222/ros_catkin_ws/build_isolated/class_loader && /home/test/l00426222/ros_catkin_ws/install_isolated/env.sh cmake /home/test/l00426222/ros_catkin_ws/src/class_loader -DCATKIN_DEVEL_PREFIX=/home/test/l00426222/ros_catkin_ws/devel_isolated/class_loader -DCMAKE_INSTALL_PREFIX=/home/test/l00426222/ros_catkin_ws/install_isolated -DCMAKE_BUILD_TYPE=Release -G 'Unix Makefiles'

Command failed, exiting.


打开编译error日志,报错如下

Performing C++ SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_92064/fast && /usr/bin/make -f CMakeFiles/cmTC_92064.dir/build.make CMakeFiles/cmTC_92064.dir/build
make[1]: 进入目录“/home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeTmp”
Building CXX object CMakeFiles/cmTC_92064.dir/src.cxx.o
/usr/bin/c++    -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_92064.dir/src.cxx.o -c /home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeTmp/src.cxx
Linking CXX executable cmTC_92064
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_92064.dir/link.txt --verbose=1
/usr/bin/c++   -DCMAKE_HAVE_LIBC_PTHREAD    CMakeFiles/cmTC_92064.dir/src.cxx.o  -o cmTC_92064 
/usr/bin/ld: CMakeFiles/cmTC_92064.dir/src.cxx.o: in function `main':
src.cxx:(.text+0x48): undefined reference to `pthread_create'
/usr/bin/ld: src.cxx:(.text+0x50): undefined reference to `pthread_detach'
/usr/bin/ld: src.cxx:(.text+0x5c): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_92064.dir/build.make:87:cmTC_92064] 错误 1
make[1]: 离开目录“/home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeTmp”
make: *** [Makefile:121:cmTC_92064/fast] 错误 2


Source file was:
#include <pthread.h>

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

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(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/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_0a6ea/fast && /usr/bin/make -f CMakeFiles/cmTC_0a6ea.dir/build.make CMakeFiles/cmTC_0a6ea.dir/build
make[1]: 进入目录“/home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeTmp”
Building CXX object CMakeFiles/cmTC_0a6ea.dir/CheckFunctionExists.cxx.o
/usr/bin/c++    -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_0a6ea.dir/CheckFunctionExists.cxx.o -c /home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CheckLibraryExists/CheckFunctionExists.cxx
Linking CXX executable cmTC_0a6ea
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0a6ea.dir/link.txt --verbose=1
/usr/bin/c++   -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_0a6ea.dir/CheckFunctionExists.cxx.o  -o cmTC_0a6ea  -lpthreads 
/usr/bin/ld: 找不到 -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_0a6ea.dir/build.make:87:cmTC_0a6ea] 错误 1
make[1]: 离开目录“/home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeTmp”
make: *** [Makefile:121:cmTC_0a6ea/fast] 错误 2


请问有人知道啥原因吗?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月31日
    • 创建了问题 12月23日

    悬赏问题

    • ¥15 ansys fluent计算闪退
    • ¥15 有关wireshark抓包的问题
    • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
    • ¥15 向数据表用newid方式插入GUID问题
    • ¥15 multisim电路设计
    • ¥20 用keil,写代码解决两个问题,用库函数
    • ¥50 ID中开关量采样信号通道、以及程序流程的设计
    • ¥15 U-Mamba/nnunetv2固定随机数种子
    • ¥15 vba使用jmail发送邮件正文里面怎么加图片
    • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。