You declared i as
Notice that this is a
declaration, not a
definition. You basically told the linker that you are relying on i being defined in another place, but the linker couldn't find any definition for i.
Is there a reason that you need the extern keyword? Dropping it should allow this to compile just fine.
Oh, and a technical point: this is actually a link error, not a compilation error. Its worth reading a little bit about the differences. It can help with your troubleshooting.