I'm currently trying to compile the https://github.com/OpenKinect/libfreenect on Ubuntu 14.04 LTS but it is failing. On CMake logs, I see errors regarding the "-pthreads" library not being found, but it finds the "-pthread" without problem. What is the difference between both? Is there any specific package for the -pthreads on Ubuntu?
3 Answers
According to the GCC man page, -pthread
and -pthreads
are architecture-specific flags. These flags are not both available for all archs. Where both flags are available, they appear to be synonyms for each other. So without seeing your exact error output, my best guess is that the error you're running into is that the "-pthreads
" flag to GCC is not available for your arch.
I suggest you read the man page for your compiler to get more information about what options are available for your particular build of your compiler.

- 4,286
- 2
- 35
- 59
In addition to jayhendren's answer:
You should avoid hardcoding architecture specific flags like -pthread
whenever possible. Instead hide them as deep down in the build system as you can so that you can easily adjust them once you need to port your project to a new platform that requires different flags for the purpose.
For threads in particular, prefer the FindThreads module to hardcoding the parameters:
find_package(Threads)
target_link_libraries(myExecutable Threads::Threads)
As you are experiencing the problem in a third-party library, you might want to file a bug report/submit a patch regarding the issue if you think that this is the only thing that prevents it from compiling on your platform.

- 1
- 1

- 51,484
- 14
- 155
- 166
-pthread and -pthreads are compiler switches. Pthreads or POSIX threads is a name of a specification and the implementation in Linux are 'LinuxThreads' and NPTL both are provided by GNU libc, the latter is newer. getconf GNU_LIBPTHREAD_VERSION
shows the implementation. man 7 pthreads instructs to use '-pthread' when compiling programs that use Pthreads.
Try again after installing 'libpthread-stubs0-dev' package.

- 8,751
- 24
- 32
-
1This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Ethaan Feb 03 '15 at 05:52