小编Cla*_*diu的帖子

CMake 找不到 pthread

pthreads 在系统上工作:

$ gcc -o what what.c
/tmp/ccI6m52b.o: In function `main':
what.c:(.text+0x37): undefined reference to `pthread_create'
what.c:(.text+0x48): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
$ gcc -pthread -o what what.c
$ ./what
In the thread.
Run Code Online (Sandbox Code Playgroud)

但是,当我cmake使用以下系统运行时CMakeLists.txt

cmake_minimum_required(VERSION 2.8.6)
FIND_PACKAGE (Threads)
Run Code Online (Sandbox Code Playgroud)

输出是:

-- Could NOT find Threads (missing:  Threads_FOUND)
Run Code Online (Sandbox Code Playgroud)

是什么赋予了?错误日志状态:

/usr/bin/cc   -std=c11 -D_GNU_SOURCE   -Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Werror -Wno-error=extra -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized -Wlogical-op -Wno-error=maybe-uninitialized -Waggregate-return -Wnested-externs …
Run Code Online (Sandbox Code Playgroud)

compiling cmake

7
推荐指数
1
解决办法
6万
查看次数

标签 统计

cmake ×1

compiling ×1