为什么extern不起作用,该如何解决

为什么extern不起作用
/*file1.c*/
int aaa=1; 

/*file2.c*/
#include <stdio.h>

extern int aaa;
 
int main()
{
printf("%d\n",aaa);

return 0;
}
我使用linux下的gcc编译器。

[everett@localhost do]$ gcc file2.c
/home/everett/tmp/ccmSoags.o: In function `main':
file2.c:(.text+0x12): undefined reference to `aaa'
collect2: ld returned 1 exit status

为什么extern不起作用?


------解决方案--------------------
It's a link error, you should compile file1.c as well