如何解决main': CheckSymbolExists.c:(.text+0x1b): 对 pthread_create
我正在使用带有命令的 cmake 构建 Faunus 软件 -->
$cmake . -DENABLE_OPENMP=ON -DENABLE_PYTHON=ON -DCMAKE_INSTALL_PREFIX:PATH=/home/user/localInstall/tstFaunusInstOpenMP -DPYTHON_EXECUTABLE=/home/user/anaconda3/envs/faunus-env/bin/python3.6 -DPYTHON_INCLUDE_DIR=/home/user/anaconda3/envs/faunus-env/include/python3.6m -DPYTHON_LIBRARY=/home/user/anaconda3/envs/faunus-env/lib -DCMAKE_CXX_FLAGS_DEBUG="-pthread"
我收到构建错误,例如:
Determining if the pthread_create exist Failed with the following output:
Change Dir: /home/user/softwares/openMPfaunus-2.4.1/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_a43c8/fast"
/usr/bin/make -f CMakeFiles/cmTC_a43c8.dir/build.make CMakeFiles/cmTC_a43c8.dir/build
make[1]: Entering directory '/home/user/softwares/openMPfaunus-2.4.1/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_a43c8.dir/CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/cmTC_a43c8.dir/CheckSymbolExists.c.o -c /home/user/softwares/openMPfaunus-2.4.1/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_a43c8
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a43c8.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTC_a43c8.dir/CheckSymbolExists.c.o -o cmTC_a43c8
/usr/bin/ld: CMakeFiles/cmTC_a43c8.dir/CheckSymbolExists.c.o: in function `main':
CheckSymbolExists.c:(.text+0x1b): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_a43c8.dir/build.make:87: cmTC_a43c8] Error 1
make[1]: Leaving directory '/home/user/softwares/openMPfaunus-2.4.1/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_a43c8/fast] Error 2
文件/home/user/softwares/openMPfaunus-2.4.1/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
}
############################################ ###############
我从中可以理解的是,文件“CheckSymbolExists.c”的一部分需要pthread_create。我在 C 中编写了一个简单的代码并使用选项运行:gcc example.c -lm -pthread 并且它工作正常但是如果我在没有 -pthread 选项的情况下运行,我会遇到关于 pthread_create 的相同错误。 有人可以帮忙吗。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。