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

CSDN问答 2021-12-30 14:07:56 阅读数:746

编译 class ros loader class_loader

执行从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/CMakeTmpRun Build Command(s):/usr/bin/make cmTC_92064/fast && /usr/bin/make -f CMakeFiles/cmTC_92064.dir/build.make CMakeFiles/cmTC_92064.dir/buildmake[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.cxxLinking 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 statusmake[1]: *** [CMakeFiles/cmTC_92064.dir/build.make:87:cmTC_92064] 错误 1make[1]: 离开目录“/home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeTmp”make: *** [Makefile:121:cmTC_92064/fast] 错误 2Source 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/CMakeTmpRun Build Command(s):/usr/bin/make cmTC_0a6ea/fast && /usr/bin/make -f CMakeFiles/cmTC_0a6ea.dir/build.make CMakeFiles/cmTC_0a6ea.dir/buildmake[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.cxxLinking 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: 找不到 -lpthreadscollect2: error: ld returned 1 exit statusmake[1]: *** [CMakeFiles/cmTC_0a6ea.dir/build.make:87:cmTC_0a6ea] 错误 1make[1]: 离开目录“/home/test/l00426222/ros_catkin_ws/build_isolated/class_loader/CMakeFiles/CMakeTmp”make: *** [Makefile:121:cmTC_0a6ea/fast] 错误 2

请问有人知道啥原因吗?

版权声明:本文为[CSDN问答]所创,转载请带上原文链接,感谢。 https://ask.csdn.net/questions/7613247