Я пытаюсь настроить проект, используя cmake, и я получаю сообщение об ошибке. Содержимое в CMakeError.log следующее
Change Dir: /home/jjcasmar/D/libs/builds/sofa/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_9feda/fast && /usr/bin/make -f CMakeFiles/cmTC_9feda.dir/build.make CMakeFiles/cmTC_9feda.dir/build
make[1]: Entering directory '/mnt/D/jjcasmar/libs/builds/sofa/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_9feda.dir/src.c.o
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD -o CMakeFiles/cmTC_9feda.dir/src.c.o -c /home/jjcasmar/D/libs/builds/sofa/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_9feda
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9feda.dir/link.txt --verbose=1
/usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD -rdynamic CMakeFiles/cmTC_9feda.dir/src.c.o -o cmTC_9feda
/usr/bin/ld: CMakeFiles/cmTC_9feda.dir/src.c.o: in function `main':
src.c:(.text+0x3e): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x4a): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x5b): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_9feda.dir/build.make:87: cmTC_9feda] Error 1
make[1]: Leaving directory '/mnt/D/jjcasmar/libs/builds/sofa/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_9feda/fast] Error 2
Source file was:
#include <pthread.h>
void* test_func(void* data)
{
return data;
}
int main(void)
{
pthread_t thread;
pthread_create(&thread, NULL, test_func, NULL);
pthread_detach(thread);
pthread_join(thread, NULL);
pthread_atfork(NULL, NULL, NULL);
pthread_exit(NULL);
return 0;
}
Тем не менее, он говорит, что компилятор правильно принимает -pthread
-- Found PythonInterp: /usr/bin/python (found version "3.8.2")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
Я попробовал очень простые CMakeLists (ниже), чтобы проверить, если pthreads работал нормально и выглядит как работает нормально (настраивает и собирает нормально)
cmake_minimum_required(VERSION 3.10)
project(Test)
find_package(Threads REQUIRED)
add_executable(Test a.cpp)
target_link_libraries(Test Threads::Threads)
со следующим выводом при настройке
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- 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
-- Found Threads: TRUE
-- Configuring done
-- Generating done
Я не уверен, как найти то, что причина проблемы. Любая идея будет полезна