How to add #include to makefile ?
-
I have a slew of common #include code I would like to put into common project makefile. Could somebody help me to accomplish that ?
#include #include #include // include b;uetooth stuff
#include <../QtBluetooth/QBluetoothLocalDevice> // localDevice;
#include <../QtBluetooth/QBluetoothAddress>
#include <../QtBluetooth/QBluetoothDeviceDiscoveryAgent>
#include <../QtBluetooth/QBluetoothServiceDiscoveryAgent>
#include <../QtBluetooth/QBluetoothHostInfo>
#include <../QtBluetooth/QBluetoothServiceInfo>
#include <../QtBluetooth/QBluetoothServer>Thanks
-
I have a slew of common #include code I would like to put into common project makefile. Could somebody help me to accomplish that ?
#include #include #include // include b;uetooth stuff
#include <../QtBluetooth/QBluetoothLocalDevice> // localDevice;
#include <../QtBluetooth/QBluetoothAddress>
#include <../QtBluetooth/QBluetoothDeviceDiscoveryAgent>
#include <../QtBluetooth/QBluetoothServiceDiscoveryAgent>
#include <../QtBluetooth/QBluetoothHostInfo>
#include <../QtBluetooth/QBluetoothServiceInfo>
#include <../QtBluetooth/QBluetoothServer>Thanks
I think you'll have to explain in more detail what you want to accomplish. Makefiles and include files are not directly related. Makefiles are "recipes" used to compile and link a binary. You write something like:
module1.o : module1.cpp inc1.h inc2.h
gcc $(CFLAGS) -o module1.o module1.cppThat would tell
make
thatmodule1.o
object file needs to be recompiled every time any ofmodule1.cpp
orinc1.h
orinc2.h
files changes and what is the command to compile it.Mircea
-
I have a slew of common #include code I would like to put into common project makefile. Could somebody help me to accomplish that ?
#include #include #include // include b;uetooth stuff
#include <../QtBluetooth/QBluetoothLocalDevice> // localDevice;
#include <../QtBluetooth/QBluetoothAddress>
#include <../QtBluetooth/QBluetoothDeviceDiscoveryAgent>
#include <../QtBluetooth/QBluetoothServiceDiscoveryAgent>
#include <../QtBluetooth/QBluetoothHostInfo>
#include <../QtBluetooth/QBluetoothServiceInfo>
#include <../QtBluetooth/QBluetoothServer>Thanks
You can groupt include statements into a single header file which is then included in every module that requires them. But you should avoid including headers that are not required as that just adds to compilation time. And if you are building for Windows with Visual Studio you can use the "Precompiled Headers" option to make it faster. I do not know whether g++ has a similar option. As mentioned elsewhere, include statements have nothing to do with make files.
-
You can groupt include statements into a single header file which is then included in every module that requires them. But you should avoid including headers that are not required as that just adds to compilation time. And if you are building for Windows with Visual Studio you can use the "Precompiled Headers" option to make it faster. I do not know whether g++ has a similar option. As mentioned elsewhere, include statements have nothing to do with make files.
g++ will create pre-compiled headers quite simply:
g++ foo.hpp
creates a foo.hpp.gch, and the compiler will search for a .gch file when processing a #include directive. If necessary, you can include-x c++-header
flags to indicate to the compiler that the named sources are to be treated as header files rather than program source code. Also note that some compiler flags need to match for both PCH and source code. More details here: [Precompiled Headers (Using the GNU Compiler Collection (GCC))](https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html)Keep Calm and Carry On