【发布时间】:2013-07-21 12:49:37
【问题描述】:
这是我的代码。
#include <stdio.h>
int main(){
int first;
int second;
int third;
float average=0.0;
printf ("This program will find the average of 3 numbers.\n");
delay(1000);
printf ("Type the first number.\n");
scanf ("%d", &first);
printf ("Type the second number.\n");
scanf ("%d", &second);
printf ("Type the third number.\n");
scanf ("%d", &third);
average = (first+second+third)/2.0;
printf ("The average of %d, %d, and %d is %.3f\n", first, second, third, average);
return (0);
}
当我使用 gcc 编译时说
Undefined symbols for architecture x86_64:
"_delay", referenced from:
_main in cc62F0GD.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
我是编码初学者。这是什么意思,我该如何解决?
【问题讨论】:
-
@H2CO3 不!
delay()有一些问题我在过去也遇到过问题,我不知道,但在 linux 上我们使用sleep(),以前(7-8 年前我什至习惯在 Redhat 中调用delay())但是现在目前在我的 ubuntu 系统中我没有delay()它通常出现在窗口基础系统上的dos.h中 -
即使我记得使用 stdlib.h 我现在尝试过但它不起作用。
-
@GrijeshChauhan 嗯?在 C 中,头文件与链接器错误无关。
-
@H2CO3 我的意思是完成回答这个问题,这是非常重要的,使用 gcc 使用 sleep() 就是这样......
标签: c gcc compiler-errors