Skip to content

cmake error (can't resolve pthread_create?) #1916

Closed
@ilya-ratner

Description

@ilya-ratner

-- Found LLVM 3.8.0
-- Added 14 tests to 'ebpf-bcc' (0 xfails)
-- Added 14 tests to 'ebpf' (0 xfails)
-- Added 5 tests to 'p4' (0 xfails)
-- Added 533 tests to 'p4' (5 xfails)
-- Added 5 tests to 'err' (0 xfails)
-- Added 160 tests to 'err' (0 xfails)
-- Added 207 tests to 'p14_to_16' (0 xfails)
-- CTest parallel: -j 4
-- Configuring incomplete, errors occurred!
See also "/home/ilya/p4/p4c/build/CMakeFiles/CMakeOutput.log".
See also "/home/ilya/p4/p4c/build/CMakeFiles/CMakeError.log".

...Below is the dump of the CMakeError.log; it appears that it can't resolve pthread_create, even though I can link with it just fine, if I use '-lpthread'

cat /home/ilya/p4/p4c/build/CMakeFiles/CMakeError.log
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_30d9b/fast"
/usr/bin/make -f CMakeFiles/cmTC_30d9b.dir/build.make CMakeFiles/cmTC_30d9b.dir/build
make[1]: Entering directory '/home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_30d9b.dir/CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/cmTC_30d9b.dir/CheckSymbolExists.c.o -c /home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_30d9b
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_30d9b.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTC_30d9b.dir/CheckSymbolExists.c.o -o cmTC_30d9b -rdynamic
CMakeFiles/cmTC_30d9b.dir/CheckSymbolExists.c.o: In function main': CheckSymbolExists.c:(.text+0x16): undefined reference to pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_30d9b.dir/build.make:97: recipe for target 'cmTC_30d9b' failed
make[1]: *** [cmTC_30d9b] Error 1
make[1]: Leaving directory '/home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_30d9b/fast' failed
make: *** [cmTC_30d9b/fast] Error 2

File /home/ilya/p4/p4c/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/ilya/p4/p4c/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_15b4a/fast"
/usr/bin/make -f CMakeFiles/cmTC_15b4a.dir/build.make CMakeFiles/cmTC_15b4a.dir/build
make[1]: Entering directory '/home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_15b4a.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_15b4a.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.5/Modules/CheckFunctionExists.c
Linking C executable cmTC_15b4a
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_15b4a.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_15b4a.dir/CheckFunctionExists.c.o -o cmTC_15b4a -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads

collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_15b4a.dir/build.make:97: recipe for target 'cmTC_15b4a' failed
make[1]: *** [cmTC_15b4a] Error 1
make[1]: Leaving directory '/home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_15b4a/fast' failed
make: *** [cmTC_15b4a/fast] Error 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionThis is a topic requesting clarification.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions