The answer is probably in a way you have configured linker. If you are linking library everything will be OK here and file3.o
module will have test_var
reference as UNDEFINED
.
If you're linking application from this 3 modules you will fail just because absence of main()
routine definition and unresolved external will be considered even less evil. :-)
Just to check it please examine appropriate *.o
modules symbol tables in your build process and then final result. Having such approach you will find the reason of your strange build behavior.