How do you compile just a .h file in a makefile?

c++, g++, makefile

Solution

You are using your class from FileName.h somewhere, aren't you? So at least one of your .cpp files should contain `#include "FileName.h"`, and .h's code will be compiled with this .cpp and you needn't compile .h's code separately.

Problem

I have a makefile that creates object files for two classes (and main) and one of those classes is just defined in a .h file. In my makefile I have a line that says ``` FileName.o: FileName.h g++ -c FileName.h ``` but when I try to compile it says it can't find FileName.o Do I have to create FileName.cpp in order to get this to compile?

Original source