尝试使用sleep()
短暂暂停我的程序。
除非我“制作”我得到一个 undefined reference to sleep
,尽管我#include <unistd.h>
在顶部。
In function `main': [...]/source/ball.c:232: undefined reference to `sleep' [...]/source/ball.c:240: undefined reference to `sleep' collect2: error: ld returned 1 exit status
我正在使用Linux。 有什么建议么? 谢谢
编辑:这不是重复的问题,因为每次询问此问题时,用户都在 Windows 上运行它。解决方案。对我来说,不仅仅是包含 Windows header 。
编辑(2):指向其他问题的链接对我没有帮助。这就是我发表新帖子的原因。我不在 Windows 上!!
最佳答案
这是一个链接器错误,而不是编译器错误(您可以从“ld returned 1 exit status”部分看到 - ld 是链接器)。因此 sleep 在 header 中声明,可以正常编译,但您需要确保在链接阶段包含正确的库/二进制文件。
关于c - Linux:对 "sleep"的 undefined reference ,即使我包含了 unistd.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50123629/