Important: Please read the Qt Code of Conduct -

Strange behavior with precompiled header on Windows only

  • Hello,

    I noticed a strange or inconsistent behavior when using a precompiled header in my project (Windows/Mac/Linux application). I include the precompiled header like this in the project file:

    CONFIG += precompile_header
    PRECOMPILED_HEADER = sourceCode/precompiledHeader.h

    When compiling with GCC in MacOSX or Linux Ubuntu, it works fine.
    Under Windows, with MinGW, I eventually get following error message from the compiler (after a few minutes of compilation):

    cc1plus.exe:-1: error: error: release\precompiledHeader.h: No such file or directory
    cc1plus.exe:-1: error: error: one or more PCH files were found, but they were invalid
    cc1plus.exe:-1: error: error: use -Winvalid-pch for more information

    It is strange because I never specify the location of the precompiled header to be in "release" folder.
    After copy and pasting the precompiled header to the "release\release" folder, it compiles fine!
    So basically, if the precompiled file is missing from one of the two above locations, it doesn't compile.

    Any idea why that is?

    I have Qt Creator 2.3.1, Qt 4.7.4 (32 bit), MinGW 4.4


Log in to reply