What's new

cmake error on debian

levani4321

Member
Member
Joined
Feb 23, 2018
Messages
38
Reaction score
0
hello someone know how to fix that error

Determining if the pthread_create exist failed with the following output:
Change Dir: /home/test/testwow335/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_e7e5b/fast"
/usr/bin/make -f CMakeFiles/cmTC_e7e5b.dir/build.make CMakeFiles/cmTC_e7e5b.dir/build
make[1]: Entering directory '/home/test/testwow335/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_e7e5b.dir/CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/cmTC_e7e5b.dir/CheckSymbolExists.c.o -c /home/test/testwow335/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_e7e5b
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e7e5b.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTC_e7e5b.dir/CheckSymbolExists.c.o -o cmTC_e7e5b -rdynamic
CMakeFiles/cmTC_e7e5b.dir/CheckSymbolExists.c.o: In function `main':
/home/test/testwow335/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c.text+0x19): undefined reference to `pthread_create'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_e7e5b.dir/build.make:97: recipe for target 'cmTC_e7e5b' failed
make[1]: *** [cmTC_e7e5b] Error 1
make[1]: Leaving directory '/home/test/testwow335/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_e7e5b/fast' failed
make: *** [cmTC_e7e5b/fast] Error 2

File /home/test/testwow335/build/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/test/testwow335/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_4eede/fast"
/usr/bin/make -f CMakeFiles/cmTC_4eede.dir/build.make CMakeFiles/cmTC_4eede.dir/build
make[1]: Entering directory '/home/test/testwow335/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_4eede.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_4eede.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.7/Modules/CheckFunctionExists.c
Linking C executable cmTC_4eede
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4eede.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_4eede.dir/CheckFunctionExists.c.o -o cmTC_4eede -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
clang: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_4eede.dir/build.make:97: recipe for target 'cmTC_4eede' failed
make[1]: *** [cmTC_4eede] Error 1
make[1]: Leaving directory '/home/test/testwow335/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_4eede/fast' failed
make: *** [cmTC_4eede/fast] Error 2
 

mastermind

Supporter
Supporter
Senior User
Joined
May 31, 2017
Messages
189
Reaction score
13
Location
PA, USA
Just a suggestion:

new gcc compiler requires that library follows the object.

Example:

gcc pthread_example.c -lpthread

instead of

gcc -lpthread pthread_example.c

Not exactly sure what you are compiling but the order the compile command is entered has been known to cause issues in new gcc.

Good luck
 
Top