【发布时间】:2021-08-26 01:48:24
【问题描述】:
我是一个长期的 python 爱好者,将脚本移植到 c。我相信环境中有问题阻止代码编译。其他地方的研究让我相信它与 posix 头文件有关?也许有宏?我在 c 方面的经验不足,无法弄清楚。
相关的sn-p在这里:
pthread_t id;
thread_create(&id, NULL, refreshqb,NULL);
void *status;
pthread_start(id, (void**)&status);
我收到的错误是这样的。
t.c:91:4: warning: implicit declaration of function 'thread_create' is invalid in C99
[-Wimplicit-function-declaration]
thread_create(&id, NULL, refreshqb,NULL);
^
t.c:93:4: warning: implicit declaration of function 'pthread_start' is invalid in C99
[-Wimplicit-function-declaration]
pthread_start(id, (void**)&status);
^
2 warnings generated.
Undefined symbols for architecture x86_64:
"_pthread_start", referenced from:
_main in t-0d3a02.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
【问题讨论】:
-
您已经声明了
pthreads.h,但您似乎没有在 C 文件中使用它。这有点令人困惑。
标签: c multithreading