Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ cmake返回错误为;未定义对pthread“u create”的引用;_C++_C_Cmake - Fatal编程技术网

C++ cmake返回错误为;未定义对pthread“u create”的引用;

C++ cmake返回错误为;未定义对pthread“u create”的引用;,c++,c,cmake,C++,C,Cmake,我正在尝试构建webrtc项目: 当我运行cmake.时,出现以下错误: WEBRTCBUILD = Release WEBRTCROOT = /home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc-streamer/../webrtc WEBRTCDESKTOPCAPTURE= ON CMAKE_CXX_COMPILER_ID=GNU ALSA_FOUND = FALSE CMake Error: The following vari

我正在尝试构建webrtc项目:

当我运行
cmake.
时,出现以下错误:

WEBRTCBUILD = Release
WEBRTCROOT = /home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc-streamer/../webrtc
WEBRTCDESKTOPCAPTURE= ON
CMAKE_CXX_COMPILER_ID=GNU
ALSA_FOUND = FALSE
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
WEBRTC_LIBRARY
    linked by target "webrtc-streamer" in directory /home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc-streamer

-- Configuring incomplete, errors occurred!
See also "/home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc-streamer/CMakeFiles/CMakeOutput.log".
See also "/home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc-streamer/CMakeFiles/CMakeError.log".
以及此后的内容“CMakeError.log”

确定pthread_create exist是否失败,输出如下:
更改目录:/home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc streamer/CMakeFiles/CMakeTmp
运行构建命令:“/usr/bin/make”“cmTC_13271/fast”
/usr/bin/make-f CMakeFiles/cmTC_13271.dir/build.make CMakeFiles/cmTC_13271.dir/build
make[1]:输入目录“/home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc streamer/CMakeFiles/CMakeTmp”
构建C对象cmakfiles/cmTC_13271.dir/CheckSymbolExists.C.o
/usr/bin/cc-fPIE-o CMakeFiles/cmtc13271.dir/CheckSymbolExists.c.o-c/home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc streamer/CMakeFiles/CMakeTmp/CheckSymbolExists.c
链接C可执行文件cmTC_13271
/usr/bin/cmake-E cmake_link_脚本CMakeFiles/cmTC_13271.dir/link.txt--verbose=1
/usr/bin/cc cmakfiles/cmTC_13271.dir/CheckSymbolExists.c.o-o cmTC_13271-rdynamic
cmakfiles/cmTC_13271.dir/CheckSymbolExists.c.o:在函数“main”中:
CheckSymbolExists.c:(.text+0x1b):未定义对“pthread_create”的引用
collect2:错误:ld返回了1个退出状态
CMakeFiles/cmTC_13271.dir/build.make:97:目标“cmTC_13271”的配方失败
make[1]:***[cmTC_13271]错误1
make[1]:离开目录“/home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc streamer/CMakeFiles/CMakeTmp”
Makefile:126:目标“cmTC_13271/fast”的配方失败
make:**[cmTC_13271/fast]错误2
文件/home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc streamer/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#包括
int main(int argc,字符**argv)
{
(无效)argv;
#ifndef pthread_创建
返回((int*)(&pthread_create))[argc];
#否则
(无效)argc;
返回0;
#恩迪夫
}
在CMakeLists.txt之后:

pthread库安装在我的ubuntu PC上,因为用-lpthread编译测试文件“test.c”不会出现问题


我缺少什么?

您需要将“pthread”添加到CMakeLists.txt中的“target\u link\u libraries”部分

[编辑]

正如@arrowd所建议的,正确的方法是使用“FindThreads”:

这是否回答了您的问题?从建议的副本中,特别是这个答案可能是相关的:@MarekR这不是关于将问题链接到pthread。这个问题是关于cmake的问题。我可以编译带有-lpthread的测试文件(.c),而不需要任何problem@MOHAMED您的错误是链接问题。第二条注释直接指向如何在cmake项目中修复它的答案(我提供了两份)。错误是没有找到
webrtc
library,它应该是
webrtc\u library
变量的值。
CMakeError.log
的内容与问题完全无关,您可以安全地将其从帖子中删除。具体来说,该行失败:。如中所述,WebRTC SDK应位于
。/WebRTC
目录下。一般来说,请确保您拥有它。正确的方法是使用
FindThreads
模块及其定义的变量。好的,谢谢您提供的信息,我不知怎么错过了。
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc-streamer/CMakeFiles/CMakeTmp

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

   
File /home/mohamed/Desktop/upwork/SoftwareExperts/test3/webrtc-streamer/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
}