简体   繁体   English

使用Autotools预编译的头文件

[英]Precompiled headers with Autotools

Is it possible to use gcc precompiled headers in projects using automake / libtool? 是否可以在使用automake / libtool的项目中使用gcc预编译头文件?

Adding new make rules to build precompiled headers is not difficult. 添加新的make规则来构建预编译头文件并不困难。 The issue is that you also have to add compilation flags introduced by libtool and AFAIK it can't handle header input files. 问题是你还必须添加由libtool和AFAIK引入的编译标志,它无法处理标头输入文件。

How can you do that? 你怎么能这样做?

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. libtool将使用与$(CXXCOMPILE)不同的编译器命令行,因此在某些系统上使用libtool时,最终无法使用预编译的头。

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' ). 我试图使用$(LTCXXCOMPILE),但它抱怨它不知道如何处理头文件(说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… 当然,它应该做的是使用project.hxx.gch作为输出文件,但我没有看到一种方法使它做到这一点,没有修改libtool脚本,这将无法使用GNU构建的目的系统…

Yes - although AFAIK there's still no built-in support for them in automake. 是的 - 虽然AFAIK在automake中仍然没有内置的支持。

I followed these instructions and got precompiled headers working in one of my projects, cutting build times in half :-) 我按照这些说明操作并在我的一个项目中使用预编译的头文件,将构建时间缩短了一半:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM