News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Precompiling headers using GCC doesn't work

Started by kbluck, October 06, 2008, 08:02:57 AM

Previous topic - Next topic

kbluck

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:


g++  -Wall -g -Winvalid-pch -include "lib/precompile.hpp"  -c /lib/precompile.hpp -o lib/precompile.h.gch


This produces the notification:


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


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

It appears that the option -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