Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to add #include to makefile ?

How to add #include to makefile ?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 3 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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

    Mircea NeacsuM L 2 Replies Last reply
    0
    • L Lost User

      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

      Mircea NeacsuM Offline
      Mircea NeacsuM Offline
      Mircea Neacsu
      wrote on last edited by
      #2

      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.cpp

      That would tell make that module1.o object file needs to be recompiled every time any of module1.cpp or inc1.h or inc2.h files changes and what is the command to compile it.

      Mircea

      1 Reply Last reply
      0
      • L Lost User

        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

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        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.

        K 1 Reply Last reply
        0
        • L Lost User

          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.

          K Offline
          K Offline
          k5054
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups