extrn.c
#include <stdio.h>
extern int var;
int main()
{
printf("%d", var);
return 0;
}
var.c
int var = 5;
I go to file extrn.c and I run the code and I get this:
undefined reference to `var'
and this is what my output is looking like:
Compile your both C
files together to fix this undefined reference
error.
gcc extrn.c var.c -o main
clang extrn.c var.c -o main