Skip to content

CMakeFile cannot find 'pthread_create' #146

Description

@WBite02
cmake CMakeLIst.txt

CMake command after Error log

Determining if the pthread_create exist failed with the following output:
Change Dir: /home/eos/Documents/eos.tools/eos-vm/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_5200c/fast"
/usr/bin/make -f CMakeFiles/cmTC_5200c.dir/build.make CMakeFiles/cmTC_5200c.dir/build

make[1]: Entering directory '/home/eos/Documents/eos.tools/eos-vm/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_5200c.dir/CheckSymbolExists.c.o
/usr/bin/cc    -o CMakeFiles/cmTC_5200c.dir/CheckSymbolExists.c.o   -c /home/eos/Documents/eos.tools/eos-vm/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_5200c
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5200c.dir/link.txt --verbose=1
/usr/bin/cc      CMakeFiles/cmTC_5200c.dir/CheckSymbolExists.c.o  -o cmTC_5200c 
CMakeFiles/cmTC_5200c.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x1b): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_5200c.dir/build.make:97: recipe for target 'cmTC_5200c' failed
make[1]: *** [cmTC_5200c] Error 1
make[1]: Leaving directory '/home/eos/Documents/eos.tools/eos-vm/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_5200c/fast' failed
make: *** [cmTC_5200c/fast] Error 2

File /home/eos/Documents/eos.tools/eos-vm/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/eos/Documents/eos.tools/eos-vm/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_6007c/fast"
/usr/bin/make -f CMakeFiles/cmTC_6007c.dir/build.make CMakeFiles/cmTC_6007c.dir/build
make[1]: Entering directory '/home/eos/Documents/eos.tools/eos-vm/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_6007c.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_6007c.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.10/Modules/CheckFunctionExists.c
Linking C executable cmTC_6007c
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_6007c.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_6007c.dir/CheckFunctionExists.c.o  -o cmTC_6007c -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_6007c.dir/build.make:97: recipe for target 'cmTC_6007c' failed
make[1]: *** [cmTC_6007c] Error 1
make[1]: Leaving directory '/home/eos/Documents/eos.tools/eos-vm/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_6007c/fast' failed
make: *** [cmTC_6007c/fast] Error 2

Why CMake compile failed?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions