【发布时间】:2020-01-18 09:41:21
【问题描述】:
我正在尝试编译 gr-gsm (https://github.com/ptrkrysik/gr-gsm) 项目。运行 cmake 时出现以下错误:
.
.
.
Building C object CMakeFiles/cmTC_5223d.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_5223d.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_5223d
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5223d.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_5223d.dir /CheckFunctionExists.c.o -o cmTC_5223d -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_5223d.dir/build.make:87: cmTC_5223d] Błąd 1
make[1]: Opuszczenie katalogu '/home/notroot/Pobrane/gr-gsm/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_5223d/fast] Błąd 2
在运行 /usr/bin/cc -lpthreads 命令后,我也出现了这个错误:
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
但不是在运行产生此输出的 /usr/bin/cc -lpthread 命令之后:
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../lib/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
我设法将所有 -lpthreads 替换为 -lpthread 标志和 grep -irl "lpthreads" ./* | xargs sed -i 's/lpthreads/lpthread/g' 命令。运行后我看到以下错误:
Building C object CMakeFiles/cmTC_5223d.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_5223d.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_5223d
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5223d.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_5223d.dir/CheckFunctionExists.c.o -o cmTC_5223d -lpthread
/usr/bin/ld: cannot find -lpthread
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_5223d.dir/build.make:87: cmTC_5223d] Błąd 1
make[1]: Opuszczenie katalogu '/home/notroot/Pobrane/gr-gsm/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_5223d/fast] Błąd 2
但是在没有 cmake ld 的情况下运行时会找到 lpthread!
【问题讨论】:
-
“运行 cmake 时出现以下错误” - 不是错误,它会阻止构建项目。您的系统具有
pthreads库只是对CMake 的检查。然后它也会检查pthread库。经过所有检查后,CMake 决定哪个库可用于 POSIX 线程功能。如果您在构建项目时遇到真正的错误,请显示cmake调用的输出 的相应部分。你显示的是CMakeErrorLog.txt文件,如果没有cmake的主要输出,查看这个文件是没有意义的。 -
这是 CMakeError.log 的最后部分
-
完整日志 - pastebin.com/QNFvpE7p
-
运行
cmake时,您会收到-- Configuring incomplete, errors occurred! See also «/home/noroot/xcicoin/Pobrane/gr-gsm/build/CMakeFiles/CMakeOutput.log»之类的消息,对吗?如果你想处理这个问题,那么首先你需要找到 actual error message,它位于 above-- Configure incomplete行。在不知道此错误消息的情况下,没有理由查看CMakeOutput.log和CMakeError.log文件。请显示来自cmake输出的实际错误消息。请注意,没有文件包含此消息。 -
不,不要查看文件,查看
cmake输出。为什么您认为构建gr-gsm失败了?你为什么要查看文件?你在哪里找到他们的名字?