Caffe: cmake error /usr/bin/ld: cannot find -lpthreads

Created on 25 Apr 2017  ·  10Comments  ·  Source: BVLC/caffe

Issue summary

I'm use cmake to compile the caffe with only_cpu,but I get the error like this:

/usr/bin/cmake -E cmake_progress_report /opt/caffe/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1767991674.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTryCompileExec1767991674.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-2.8/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec1767991674
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1767991674.dir/link.txt --verbose=1
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTryCompileExec1767991674.dir/CheckFunctionExists.c.o  -o cmTryCompileExec1767991674 -rdynamic -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status

Steps to reproduce

1.install the dependencies
2.git clone the project

  1. pip install the requirements
    4.mkdir build && cd build && cmake -DCPU_ONLY=1

Your system configuration

Operating system: Ubuntu 14.04
Compiler: gcc-4.9

All 10 comments

I have the same issue. I think "-lpthreads" is a typo. It should probably be "-lpthread" according to this. Seems like a cmake issue to me but I am not sure.

Same issue affects me...Any solution to this?

Yes, this error seen in CMakeError.log is due to the way cmake uses to look for pthread_createmethod.

So if cmake ..shows the following:

-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found

Then all is well.

I met the same error, can anyone help me?

my error message is below:
Run Build Command:"/usr/bin/make" "cmTC_2f64b/fast" /usr/bin/make -f CMakeFiles/cmTC_2f64b.dir/build.make CMakeFiles/cmTC_2f64b.dir/build make[1]: Entering directory '/home/idc/TextBoxes/build/CMakeFiles/CMakeTmp' Building C object CMakeFiles/cmTC_2f64b.dir/CheckFunctionExists.c.o /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_2f64b.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.5/Modules/CheckFunctionExists.c Linking C executable cmTC_2f64b /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2f64b.dir/link.txt --verbose=1 /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_2f64b.dir/CheckFunctionExists.c.o -o cmTC_2f64b -rdynamic -lpthreads /usr/bin/ld: 找不到 -lpthreads collect2: error: ld returned 1 exit status CMakeFiles/cmTC_2f64b.dir/build.make:97: recipe for target 'cmTC_2f64b' failed make[1]: *** [cmTC_2f64b] Error 1 make[1]: Leaving directory '/home/idc/TextBoxes/build/CMakeFiles/CMakeTmp' Makefile:126: recipe for target 'cmTC_2f64b/fast' failed make: *** [cmTC_2f64b/fast] Error 2

Yes, even I get that error, because cmakefirst checks for pthread_create in pthreadsand then it checks it in pthread .

Could you please post complete output of cmake ..

someone?
I met the same error, can anyone help me?

I met the same error, does anyone solve this problem?

not sure if this helps, but in my case it was an issue related to lack of some BOOST libraries.

I solved by installing all of them with command

sudo apt install libboost-all-dev

Hope this helps!

I also met this problem, my OS is Ubuntu 16.04, and I really have the pthread.so, but it won't use it. On the Internet, most people say it is should use "gcc -pthread ....", seems that the code have the "gcc -lpthreads...", but I not sure, and hope the developer could help us.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LarsHH picture LarsHH  ·  3Comments

OpenHero picture OpenHero  ·  3Comments

kelvinxu picture kelvinxu  ·  3Comments

malreddysid picture malreddysid  ·  3Comments

weather319 picture weather319  ·  3Comments