Hi,
I have two files extern_function.c and extern_file.c.
// extern_file.c
int x =20;
int getData()
{
return 20;
}
// extern_function.c
extern int getValue();
extern int k;
int main()
{
printf("%d\n", getValue());
getInput();
return 0;
}
int getInput(){
printf(" Value:-%d ",k);
return 0;
}
i compile it using gcc.
gcc extern_file.c extern_function.c
Undefined first referenced
symbol in file
k /var/tmp//ccctm19K.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
Why is that the function getValue() works with extern and not k?
I commented out the printf("%d",k);
Is there something else i need in order to get the object files linked?
Thanks
Sadhana