Issue
As the title asks, do object files have to have the same name as the header file in order to be properly linked?
ie. could I have a header file 'foo.h' and call it 'bar.o' and still have it properly link?
In source code, I would still need to write include "foo.h"
so I speculate that the linker will reject this since the two do not share the same name.
Solution
There is nothing that says a particular header file is associated with a particular object file.
A header file typically contains only declarations. It does not say anything regarding where the associated definitions reside. You could have two source files such as main.c and foo.c and have both use a header file called common.h. When you compile, you could then create main.o and foo.o and link them together into "myprogram".
Answered By - dbush Answer Checked By - Katrina (WPSolving Volunteer)