How to use precompiled headers (pch) for C++ with Qt
-
wrote on 12 Oct 2023, 02:14 last edited by
Tried to google a little, but information is not much consistent...
Need to build faster my custom headers and Qt core/gui/widgets headers too -
Tried to google a little, but information is not much consistent...
Need to build faster my custom headers and Qt core/gui/widgets headers toowrote on 12 Oct 2023, 03:54 last edited byqmake: Using Precompiled Headers
cmake: target_precompile_headers -
qmake: Using Precompiled Headers
cmake: target_precompile_headerswrote on 12 Oct 2023, 09:23 last edited by JacobNovitsky 10 Dec 2023, 09:29@ChrisW67 thanks :)
do you have real code sample I could refer to?as I can see the process, I need to insert
/* Add C includes here */ #if defined __cplusplus /* Add C++ includes here */ # include <iostream> # include <QApplication> # include <QPushButton> # include <QLabel> #endif
before every qt header and add smth to qt pro file?
-
@ChrisW67 thanks :)
do you have real code sample I could refer to?as I can see the process, I need to insert
/* Add C includes here */ #if defined __cplusplus /* Add C++ includes here */ # include <iostream> # include <QApplication> # include <QPushButton> # include <QLabel> #endif
before every qt header and add smth to qt pro file?
wrote on 12 Oct 2023, 11:48 last edited by mpergand 10 Dec 2023, 11:55@JacobNovitsky
Here my own example:.pro file
CONFIG += precompile_header PRECOMPILED_HEADER = $$PWD/Application/Headers.pch
Headers.pch
// Prefix header #ifdef __cplusplus #include "QtMacros.h" #include "QtAppDefs.h" #endif
And you don't need to insert anything in your .h .cpp files.
-
@JacobNovitsky
Here my own example:.pro file
CONFIG += precompile_header PRECOMPILED_HEADER = $$PWD/Application/Headers.pch
Headers.pch
// Prefix header #ifdef __cplusplus #include "QtMacros.h" #include "QtAppDefs.h" #endif
And you don't need to insert anything in your .h .cpp files.
wrote on 15 Oct 2023, 03:45 last edited by@mpergand is it nessesary to change .h to .pch or I can use .h file too?
-
@mpergand is it nessesary to change .h to .pch or I can use .h file too?
wrote on 15 Oct 2023, 06:00 last edited by@JacobNovitsky Call the file whatever you like.
-
-
@JacobNovitsky Call the file whatever you like.
wrote on 15 Oct 2023, 06:20 last edited by@ChrisW67 how to test if its already pre-compiled, my complier does not compile this particular header?
https://forum.qt.io/topic/151001/additional-info-upon-compiling-with-qt-creator -
@ChrisW67 how to test if its already pre-compiled, my complier does not compile this particular header?
https://forum.qt.io/topic/151001/additional-info-upon-compiling-with-qt-creatorwrote on 15 Oct 2023, 06:51 last edited by@JacobNovitsky Please stop creating new threads for the same conversation.
-
-
-
@JacobNovitsky Please stop creating new threads for the same conversation.
-
3/9