简体   繁体   中英

Precompiled Headers with Qt and g++ (QtCreator)

I'm using precompiled headers on a Qt project to speed up compilation time. I'm using Qt 4.6.2 .When I compile the project using macx-g++ (meaning the g++ compiler) it doesn't include the stdafx.h automatically for each header. When compiling under xcode it will work. I'm using the PRECOMPILED_HEADER qmake constant to point at my stdafx.h.

So is it a limitation from g++? Or there a solution/work around?

Thanks for your help, Boris -

Sometimes gcc ignores precompiled header if some conditions aren't met. see: gcc documentation page .

Compile headers just like any other files but put the output inside a file with a suffix of .gch:

g++ -c stdafx.h -o stdafx.h.gch
g++ main.cpp
./main.out

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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