Author Topic: Precompiling headers using GCC doesn't work  (Read 2090 times)

kbluck

  • Guest
Precompiling headers using GCC doesn't work
« on: October 06, 2008, 08:02:57 am »
Using Code::Blocks 8.02

I'm attempting to precompile a header using GCC to a GCH target. In my project, the header in question is selected for compilation, but not linking. The command-line which is generated by Code::Blocks during the build is:

Code: [Select]
g++  -Wall -g -Winvalid-pch -include "lib/precompile.hpp"  -c /lib/precompile.hpp -o lib/precompile.h.gch

This produces the notification:

Code: [Select]
g++: lib/precompile.hpp: linker input file unused because linking not done

... and the .gch target is not generated.

It appears that the option
Code: [Select]
-x c++-header is not being inserted into the GCC command line to inform the compiler that it is generating a precompiled header rather than an obj. When I manually add that option before the -c the compile succeeds, producing the expected .gch file.

Can anybody point out to me what I am failing to specify correctly in the project properties or build options? I can't find any obvious way to tell Code::Blocks that this file should be compiled a bit differently than the average .cpp file except by specifying a custom build command.

Thanks,

--- Kevin