The following code gave error on gcc compiler

Code:
int main()
{
extern int a;
printf("%d",a);
return 0;
}
static int a=5;
But when static is removed from int a then it runs with no errors..Can someone please clear the doubt??