I am getting a linking error when i run my program, even though the function signature is the same for both functions in test.h and test.c :
test.h :
void function(int);
test.c :
#include "test.h"
#include "stdio.h"
static void function(int n) {
printf("%d\n", n);
}
main.c :
#include "test.h"
int main() {
function(5);
return 0;
}
this is the output:
Undefined symbols for architecture x86_64:
"_function", referenced from:
_main in ccNaA2H2.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
In class, I learned that the function signature is the function name and its parameters. So, why doesn't my program in main call function(5) in test.h which will call the function(5) in test.c ?
Thank you