I'm trying to follow the tutorial here:
http://cocoadevcentral.com/articles/000081.php
And soon as I reached the "Header files" section, I kept getting a strange error message after running gcc test1.c -o test1
in the Mac OSX command line:
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;
}
And finally, my 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);
}
I seem to have followed everything correctly and I don't understand where that error is coming from. Help?