Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Precompiled headers with Autotools

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?

like image 937
Dj Gaspa Avatar asked Sep 03 '09 09:09

Dj Gaspa


People also ask

Should you use precompiled headers?

Usage of precompiled headers may significantly reduce compilation time, especially when applied to large header files, header files that include many other header files, or header files that are included in many translation units.

How do I precompile a header file?

The compiler options for precompiled headers are /Y . In the project property pages, the options are located under Configuration Properties > C/C++ > Precompiled Headers. You can choose to not use precompiled headers, and you can specify the header file name and the name and path of the output file.

How do I not use precompiled headers?

To turn off precompiled headersSelect the Configuration properties > C/C++ > Precompiled Headers property page. In the property list, select the drop-down for the Precompiled Header property, and then choose Not Using Precompiled Headers.

How do I create a precompiled header in Visual Studio?

Configure Visual Studio to create precompiled headerschoose "All Configurations", then go to C/C++ -> Precompiled Headers, choose "Create Precompiled Header", make sure stdafx. h is the header file to use, and leave the rest to the default value.


1 Answers

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…

like image 146
Michael Trausch Avatar answered Sep 26 '22 04:09

Michael Trausch