【发布时间】:2012-07-16 09:10:05
【问题描述】:
我正在尝试按照这里的教程进行操作:
http://cocoadevcentral.com/articles/000081.php
当我到达“头文件”部分时,在 Mac OSX 命令行中运行 gcc test1.c -o test1 后,我不断收到一条奇怪的错误消息:
Undefined symbols for architecture x86_64:
"_sum", referenced from:
_main in ccdZyc82.o
"_average", referenced from:
_main in ccdZyc82.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
math_functions.h:
int sum(int x, int y);
float average(float x, float y, float z);
math_functions.c:
int sum(int x, int y) {
return x + y;
}
float average(float x, float y, float z) {
return (x + y + z)/3;
}
最后,我的 test1.c:
#include <stdio.h>
#include "math_functions.h"
main() {
int thesum = sum(1, 2);
float ave = average(1.1, 2.21, 55.32);
printf("sum = %i\nave = %f\n(int)ave = %i\n", thesum, ave, (int)ave);
}
我似乎正确地遵循了一切,但我不明白该错误来自何处。帮忙?
【问题讨论】:
-
stackoverflow.com/questions/1754460/… 希望对您有所帮助。
标签: objective-c ios