Suppose I have A.h, A.cpp, B.h and B.h.gch (I have downloaded B from Internet)
How can I compile my code (and create an executable) ?
I have an error when I do
g++ -c B.h.gch
Suppose I have A.h, A.cpp, B.h and B.h.gch (I have downloaded B from Internet)
How can I compile my code (and create an executable) ?
I have an error when I do
g++ -c B.h.gch
You can practically have only one single precompiled header myheader.h
and quite often that single header is including other ones. See this answer for more.
You compile that C++ header with g++ -c myheader.h
(and other relevant options, notably -O
, -g
, -Wall
, -I
dirname ...; they should be the same as for your object files). In practice you should have a Makefile
and use make
(run once make -p
to understand the builtin rules). The CXXFLAGS
there should be used both for object files and for the precompiled header.
You don't change any #include
directive (but in practice all your *.cc
or *.cpp
files should have only one).
Read also the Precompiled headers section.