Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could NOT find Threads (missing: Threads_FOUND) #2

Closed
mario-pinderi opened this issue Jun 26, 2018 · 15 comments
Closed

Could NOT find Threads (missing: Threads_FOUND) #2

mario-pinderi opened this issue Jun 26, 2018 · 15 comments
Labels

Comments

@mario-pinderi
Copy link

mario-pinderi commented Jun 26, 2018

Hi!
I'm trying to build geogram in Ami Linux but I'm getting error. Below you will fin the error:

============= Checking for CMake ============

cmake version 3.10.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).
Found CMake

============= Creating makefiles for Linux64-gcc-dynamic-Release ============

-- The C compiler identification is GNU 7.2.1
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring build for standalone Geogram (without Vorpaline)
-- GCC version >= 4.3, activating sign conversion warnings
-- GCC version >= 4.6, activating double promotion warnings
-- Did not find GLFW3 in the system, using built-in GLFW3.
-- Looking for pthread.h
-- Looking for pthread.h - not found
CMake Error at /usr/local/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
/usr/local/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-3.10/Modules/FindThreads.cmake:205 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
src/lib/third_party/glfw/CMakeLists.txt:70 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/ec2-user/libraries/geogram/build/Linux64-gcc-dynamic-Release/CMakeFiles/CMakeOutput.log".
See also "/home/ec2-user/libraries/geogram/build/Linux64-gcc-dynamic-Release/CMakeFiles/CMakeError.log".

============= Creating makefiles for Linux64-gcc-dynamic-Debug ============

-- The C compiler identification is GNU 7.2.1
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring build for standalone Geogram (without Vorpaline)
-- GCC version >= 4.3, activating sign conversion warnings
-- GCC version >= 4.6, activating double promotion warnings
-- Did not find GLFW3 in the system, using built-in GLFW3.
-- Looking for pthread.h
-- Looking for pthread.h - not found
CMake Error at /usr/local/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
/usr/local/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-3.10/Modules/FindThreads.cmake:205 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
src/lib/third_party/glfw/CMakeLists.txt:70 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/ec2-user/libraries/geogram/build/Linux64-gcc-dynamic-Debug/CMakeFiles/CMakeOutput.log".
See also "/home/ec2-user/libraries/geogram/build/Linux64-gcc-dynamic-Debug/CMakeFiles/CMakeError.log".

============== Geogram build configured ==================

To build geogram:

  • go to build/Linux64-gcc-dynamic-Release or build/Linux64-gcc-dynamic-Debug
  • run 'make' or 'cmake --build .'

Note: local configuration can be specified in CMakeOptions.txt
(see CMakeOptions.txt.sample for an example)
You'll need to re-run configure.sh if you create or modify CMakeOptions.txt

@simogasp
Copy link
Member

Hi,
I think you need to install libpthread (it should be sudo apt-get install libpthread-stubs0-dev)
Also pay attention to this line

-- The C compiler identification is GNU 7.2.1
-- The CXX compiler identification is GNU 4.8.5

It seems like you have different versions installed for the c and c++ compiler. You may need to install g++7 to use the same version for c and c++

@mario-pinderi
Copy link
Author

Hi,
I updated c++ and I can confirm that libpthread-stubs is installed. I'm using Ami Linux for this.
If you see this line:
Did not find GLFW3 in the system, using built-in GLFW3
It says that it can't find GLFW3, I can confirm that GLFW3 is installed without any error.

============= Checking for CMake ============

cmake version 3.11.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).
Found CMake


============= Creating makefiles for Linux64-gcc-dynamic-Release ============

-- Configuring build for standalone Geogram (without Vorpaline)
-- GCC version >= 4.3, activating sign conversion warnings
-- GCC version >= 4.6, activating double promotion warnings
-- Did not find GLFW3 in the system, using built-in GLFW3.
CMake Error at /usr/local/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.11/Modules/FindThreads.cmake:205 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  src/lib/third_party/glfw/CMakeLists.txt:70 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/ec2-user/libraries/geogram/CMakeFiles/CMakeOutput.log".
See also "/home/ec2-user/libraries/geogram/CMakeFiles/CMakeError.log".

============= Creating makefiles for Linux64-gcc-dynamic-Debug ============

-- Configuring build for standalone Geogram (without Vorpaline)
-- GCC version >= 4.3, activating sign conversion warnings
-- GCC version >= 4.6, activating double promotion warnings
-- Did not find GLFW3 in the system, using built-in GLFW3.
CMake Error at /usr/local/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.11/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.11/Modules/FindThreads.cmake:205 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  src/lib/third_party/glfw/CMakeLists.txt:70 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/ec2-user/libraries/geogram/CMakeFiles/CMakeOutput.log".
See also "/home/ec2-user/libraries/geogram/CMakeFiles/CMakeError.log".

============== Geogram build configured ==================

To build geogram:
  - go to build/Linux64-gcc-dynamic-Release or build/Linux64-gcc-dynamic-Debug
  - run 'make' or 'cmake --build .'

Note: local configuration can be specified in CMakeOptions.txt
(see CMakeOptions.txt.sample for an example)
You'll need to re-run configure.sh if you create or modify CMakeOptions.txt

@simogasp
Copy link
Member

what does

locate libpthread.so

and

locate pthread.h

say?

@mario-pinderi
Copy link
Author

libpthread.so :

/var/lib/docker/overlay2/c2a718a936105a3f3adfbd51fe6121df428cb6216e088aa215153a92dfffd393/diff/usr/lib/x86_64-linux-gnu/libpthread.so
/var/lib/docker/overlay2/e49b8aebcd3e79a3b3655ae86303e4b5cc34257581d439263f6217ec8d07a4c2/merged/usr/lib/x86_64-linux-gnu/libpthread.so
/var/lib/docker/overlay2/c2734637d0a5954b594b92f02854a21eb50707a40da798997e8047130530e900/diff/usr/libx32/libpthread.so
/var/lib/docker/overlay2/c2734637d0a5954b594b92f02854a21eb50707a40da798997e8047130530e900/diff/usr/lib/x86_64-linux-gnu/libpthread.so
/var/lib/docker/overlay2/c2734637d0a5954b594b92f02854a21eb50707a40da798997e8047130530e900/diff/usr/lib32/libpthread.so
/usr/lib64/libpthread.so

pthread.h :

/var/lib/docker/overlay2/c2a718a936105a3f3adfbd51fe6121df428cb6216e088aa215153a92dfffd393/diff/usr/include/pthread.h
/var/lib/docker/overlay2/e49b8aebcd3e79a3b3655ae86303e4b5cc34257581d439263f6217ec8d07a4c2/merged/usr/include/pthread.h
/var/lib/docker/overlay2/c2734637d0a5954b594b92f02854a21eb50707a40da798997e8047130530e900/diff/usr/include/pthread.h
/usr/include/pthread.h
/usr/x86_64-w64-mingw32/sys-root/mingw/include/pthread.h

@vishav26
Copy link

Hi @mariopinderist @simogasp ,

Did anyone of you find the solution because I am also facing the same issue.

@mkhairy
Copy link

mkhairy commented Jul 11, 2019

Hi @vishav26 @mariopinderist ,

Did you guys find a solution for this issue? Thanks!

@tkircher
Copy link

tkircher commented Oct 1, 2019

I'm having this issue too. Edit: Solved it by including this in the top-level CMakeLists.txt:

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

Found this suggestion in another forum somewhere.

@one-and-only
Copy link

Indeed! works for me.

@simogasp simogasp added the build label Apr 13, 2020
@mr-sobol
Copy link

Thank so much!

@MiguelBtt
Copy link

It works perfectly!!!

@joyoFeng
Copy link

I'm having this issue too. Edit: Solved it by including this in the top-level CMakeLists.txt:

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

Found this suggestion in another forum somewhere.

that is cool, fix for me. Thank you

@rubyFeedback
Copy link

rubyFeedback commented Jun 23, 2020

tkircher's code solved this for me. Hopefully the webkitgtk guys include that solution because I am having to use his workaround for the same problem (even recent webkitgtk does not find threads, unless I add the above code to the cmake file).

@VanHoevenTR
Copy link

Thank you tkircher. It also solved the problem on my other llvm project

@MiltosKoutsokeras
Copy link

I'm having this issue too. Edit: Solved it by including this in the top-level CMakeLists.txt:

set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

Found this suggestion in another forum somewhere.

Unfortunately this trick is not applicable to every environment. I do not build geogram, but I encountered the missing pthread functions during linking. It worked while building with CMake cross compilation an armhf target in Debian 10 and same sources fail in Arch Linux. So the trick is nice, but there are corner cases which fails. It seems that compilers or CMake have trouble with -pthreads flag. It seems that pthread shared objects are symlinked differently in every system, breaking builds. Unfortunatelly the only fix I managed to see working everywhere is linking straight to the SO file with absolute path. Something like this in CMake:

TARGET_LINK_LIBRARIES(my_target
#	${CMAKE_THREAD_LIBS_INIT} # FAILS
#	/opt/cross-toolchains/arm-linux-gnueabihf/lib/libpthread.so # FAILS
	/opt/cross-toolchains/arm-linux-gnueabihf/lib/libpthread-2.28.so # WORKS
#	/opt/cross-toolchains/arm-linux-gnueabihf/lib/libpthread.so.0 # FAILS
)

Where libpthread-2.28.so is the SO and libpthread.so is symlink to libpthread.so.0 which in turns is symlink to libpthread-2.28.so:

/opt/cross-toolchains/arm-linux-gnueabihf/lib/libpthread-2.28.so
/opt/cross-toolchains/arm-linux-gnueabihf/lib/libpthread.so -> libpthread.so.0
/opt/cross-toolchains/arm-linux-gnueabihf/lib/libpthread.so.0 -> libpthread-2.28.so

@jalapatip
Copy link

jalapatip commented Jun 29, 2021

@tkircher, I'm installing the librealsense package from source using HomeBrew and got the below error.

CMake Error at /opt/homebrew/Cellar/cmake/3.20.5/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.20.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/opt/homebrew/Cellar/cmake/3.20.5/share/cmake/Modules/FindThreads.cmake:238 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
examples/measure/CMakeLists.txt:9 (find_package)

I tried updating the config in the CMakeLists.txt like you mentioned above but see that there are multiple CMakeLists.txt files in the package hierarchy. Which file do I make the changes to?

Also, I installed using 'brew install --build-from-source librealsense' as I was getting the following error with 'brew install'

'Error: librealsense: no bottle available!'

Update: The issue is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests