librealsense: Failed to build Could NOT find Threads (missing: Threads_FOUND)

| Operating System & Version | MacOS Monterey 12.0.1 M1 chip |

I do have much experience with CMake.

I downloaded folder using: it clone https://github.com/IntelRealSense/librealsense

and then followed the steps for MacOS

When I want to build it cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false

This occurs build % cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -- Checking internet connection... -- Internet connection identified -- Info: REALSENSE_VERSION_STRING=2.50.0 -- Setting Unix configurations -- using RS2_USE_LIBUVC_BACKEND CMake Error at /opt/homebrew/Cellar/cmake/3.22.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find Threads (missing: Threads_FOUND) Call Stack (most recent call first): /opt/homebrew/Cellar/cmake/3.22.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE) /opt/homebrew/Cellar/cmake/3.22.0/share/cmake/Modules/FindThreads.cmake:238 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) examples/measure/CMakeLists.txt:9 (find_package)

After first run I got this -- Looking for pthread.h -- Looking for pthread.h - not found CMake Error at /opt/homebrew/Cellar/cmake/3.22.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find Threads (missing: Threads_FOUND) Call Stack (most recent call first): /opt/homebrew/Cellar/cmake/3.22.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE) /opt/homebrew/Cellar/cmake/3.22.0/share/cmake/Modules/FindThreads.cmake:238 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) examples/measure/CMakeLists.txt:9 (find_package)

I don’t want to make it too long but here is CMakeError.log

Compiling the CXX compiler identification source file “CMakeCXXCompilerId.cpp” failed. Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ Build flags: Id flags:

The output was: 1 ld: library not found for -lc++ clang: error: linker command failed with exit code 1 (use -v to see invocation)

Compiling the C compiler identification source file “CMakeCCompilerId.c” failed. Compiler: /Library/Developer/CommandLineTools/usr/bin/cc Build flags: Id flags:

The output was: 1 ld: library not found for -lSystem clang: error: linker command failed with exit code 1 (use -v to see invocation)

Determining if the include file pthread.h exists failed with the following output: Change Dir: /Users/Obrepal/librealsense/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make -f Makefile cmTC_5e8f1/fast && /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_5e8f1.dir/build.make CMakeFiles/cmTC_5e8f1.dir/build Building C object CMakeFiles/cmTC_5e8f1.dir/CheckIncludeFile.c.o /Library/Developer/CommandLineTools/usr/bin/cc -pedantic -g -D_DEFAULT_SOURCE -mfpu=neon -mfloat-abi=hard -ftree-vectorize -latomic -pthread -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk -fPIE -MD -MT CMakeFiles/cmTC_5e8f1.dir/CheckIncludeFile.c.o -MF CMakeFiles/cmTC_5e8f1.dir/CheckIncludeFile.c.o.d -o CMakeFiles/cmTC_5e8f1.dir/CheckIncludeFile.c.o -c /Users/Obrepal/librealsense/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c clang: warning: -latomic: ‘linker’ input unused [-Wunused-command-line-argument] clang: warning: argument unused during compilation: ‘-mfpu=neon’ [-Wunused-command-line-argument] clang: warning: argument unused during compilation: ‘-mfloat-abi=hard’ [-Wunused-command-line-argument] Linking C executable cmTC_5e8f1 /opt/homebrew/Cellar/cmake/3.22.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5e8f1.dir/link.txt --verbose=1 /Library/Developer/CommandLineTools/usr/bin/cc -pedantic -g -D_DEFAULT_SOURCE -mfpu=neon -mfloat-abi=hard -ftree-vectorize -latomic -pthread -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_5e8f1.dir/CheckIncludeFile.c.o -o cmTC_5e8f1 ld: library not found for -latomic clang: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [cmTC_5e8f1] Error 1 make: *** [cmTC_5e8f1/fast] Error 2

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 27

Most upvoted comments

There is a librealsense example of this ‘Threads’ CMake error at https://github.com/IntelRealSense/librealsense/issues/5656

In a non-librealsense discussion, someone who encountered the same issue with CMake shared the following advice.


I solve this problem by adding find_package(Threads) to the CMakeLists.txt file in the root directory.