views:

293

answers:

2

Is it possible to use gcc precompiled headers in projects using automake / libtool?

Adding new make rules to build precompiled headers is not difficult. The issue is that you also have to add compilation flags introduced by libtool and AFAIK it can't handle header input files.

How can you do that?

A: 

Yes - although AFAIK there's still no built-in support for them in automake.

I followed these instructions and got precompiled headers working in one of my projects, cutting build times in half :-)

Nick Dowell
A: 

Problem is that solution does not work on all systems; libtool will use a different compiler command line than $(CXXCOMPILE), so when using libtool on some systems you wind up with not being able to use the precompiled header.

I have not yet found a way to work around this; I tried to use $(LTCXXCOMPILE), but it complains that it does not know how to deal with a header file (saying libtool: compile: cannot determine name of library object from 'project.hxx'). Of course, what it should do is use project.hxx.gch as the output file, but I don't see a way to make it do that short of modifying the libtool script, and that would defeat the purpose of using the GNU build system…

Michael Trausch