extern is used to refer to variables from different compilation units – not necessarily a file but typically a file. By including one file in another you are currently having a single compilation unit. Compile the two files separately using “gcc -c ” and link them using “gcc” into a single executable. You can see the use of “extern”.