[Bug 255123] cmake compiler test fails with pthread
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sat Apr 24 13:35:35 BST 2021
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255123
--- Comment #4 from Mohammad S. Babaei <info at babaei.net> ---
This is the simplest program I can reproduce it with:
$ cat main.cpp
int main()
{
return 0
}
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.14...3.20)
project(Barandazstorm
VERSION 0.0.0
DESCRIPTION "A Twitter analysis tool dedicated to #IranRegimeChange"
HOMEPAGE_URL "https://twitter.com/Barandazstorm"
LANGUAGES C CXX
)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
add_executable(hello main.cpp)
target_link_libraries(hello
PRIVATE
Threads::Threads
)
$ cmake -GNinja -S . -B build
-- The C compiler identification is Clang 10.0.1
-- The CXX compiler identification is Clang 10.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- 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
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/home/mamadou/test-cmake/build
$ cat build/CMakeFiles/CMakeError.log
Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following
output:
Change Dir: /usr/home/mamadou/test-cmake/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/local/bin/ninja cmTC_230ca && [1/2] Building C object
CMakeFiles/cmTC_230ca.dir/src.c.o
[2/2] Linking C executable cmTC_230ca
FAILED: cmTC_230ca
: && /usr/bin/cc CMakeFiles/cmTC_230ca.dir/src.c.o -o cmTC_230ca && :
ld: error: undefined symbol: pthread_create
>>> referenced by src.c
>>> CMakeFiles/cmTC_230ca.dir/src.c.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Source file was:
#include <pthread.h>
static void* test_func(void* data)
{
return data;
}
int main(void)
{
pthread_t thread;
pthread_create(&thread, NULL, test_func, NULL);
pthread_detach(thread);
pthread_cancel(thread);
pthread_join(thread, NULL);
pthread_atfork(NULL, NULL, NULL);
pthread_exit(NULL);
return 0;
}
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the kde-freebsd
mailing list