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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Compiling DLL - what is the sequence of compilation? SOLVED

Compiling DLL - what is the sequence of compilation? SOLVED

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++tutorial
7 Posts 3 Posters 1 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.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    I would like to have a common header file in a simple DLL I am building. I would like to have common headers, classes forward declarations and their headers in it. How do I make sure my common header is compiled first? It seems that the complier works on the classes in a sequence they were added to the DLL. Any pointers will be as always appreciated. Cheers Vaclav After several attempts to build DirectShow filter using sample code I found here and in SDK I am totally lost how to build simple DLL with more than one class. It appears that having identical include header files in each cpp file compiles / links OK. I even tryied #pragma once and it did not stop this behavior. This leads me to believe that having common file in simple DLL is not possible. I guess I need some pointers on how this works and why. The answer: The sequence of compilation is given in the project DSP file ( VC6.0 )

    L 1 Reply Last reply
    0
    • V Vaclav_

      I would like to have a common header file in a simple DLL I am building. I would like to have common headers, classes forward declarations and their headers in it. How do I make sure my common header is compiled first? It seems that the complier works on the classes in a sequence they were added to the DLL. Any pointers will be as always appreciated. Cheers Vaclav After several attempts to build DirectShow filter using sample code I found here and in SDK I am totally lost how to build simple DLL with more than one class. It appears that having identical include header files in each cpp file compiles / links OK. I even tryied #pragma once and it did not stop this behavior. This leads me to believe that having common file in simple DLL is not possible. I guess I need some pointers on how this works and why. The answer: The sequence of compilation is given in the project DSP file ( VC6.0 )

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

      I'm not sure what you are asking here. Header files are used to compile source into object code, they have nothing to do with the final product being a DLL or anything else. In terms of compilation sequence, C/C++ tends to work on a single pass forward direction compilation. That is to say any reference that it comes upon in the source code must have a definition provided earlier in the source. This would be in the current .CPP file or in one of the headers that have been previously included.

      V 1 Reply Last reply
      0
      • L Lost User

        I'm not sure what you are asking here. Header files are used to compile source into object code, they have nothing to do with the final product being a DLL or anything else. In terms of compilation sequence, C/C++ tends to work on a single pass forward direction compilation. That is to say any reference that it comes upon in the source code must have a definition provided earlier in the source. This would be in the current .CPP file or in one of the headers that have been previously included.

        V Offline
        V Offline
        Vaclav_
        wrote on last edited by
        #3

        In standard MFC wizard build application there is an option to have precompiled header - StdAfx.h I put all my forward class declarations and all of my headers ( in proper order ) there. I would like to do same in simple ( empty ) DLL and build a common header. I suppose I could put this common header in #ifndef / #define / #endif in each header file to avoid multiple definitions. That way the sequence of compilation would not matter.

        G L 2 Replies Last reply
        0
        • V Vaclav_

          In standard MFC wizard build application there is an option to have precompiled header - StdAfx.h I put all my forward class declarations and all of my headers ( in proper order ) there. I would like to do same in simple ( empty ) DLL and build a common header. I suppose I could put this common header in #ifndef / #define / #endif in each header file to avoid multiple definitions. That way the sequence of compilation would not matter.

          G Offline
          G Offline
          Gisle Vanem
          wrote on last edited by
          #4

          Off-course you should always use header-guards in .h-files: #ifndef _FOO_H #define FOO_H ... #endif But what has this to do with making DLLs? Maybe you have a problem with export & import of the classes+data in those headers? You didn't say, be specific.

          -- Gisle V.

          1 Reply Last reply
          0
          • V Vaclav_

            In standard MFC wizard build application there is an option to have precompiled header - StdAfx.h I put all my forward class declarations and all of my headers ( in proper order ) there. I would like to do same in simple ( empty ) DLL and build a common header. I suppose I could put this common header in #ifndef / #define / #endif in each header file to avoid multiple definitions. That way the sequence of compilation would not matter.

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

            Vaclav_Sal wrote:

            I would like to do same in simple ( empty ) DLL

            As I said before, header files have nothing to do with DLLs. The reason for using StdAfx.h in a project is merely to speed up the compilation phase since all the preprocessing of the header files is done once and then saved in internal format that the compiler can quickly read. You can use exactly the same thing in a project that is to create a DLL. And the sequence of headers does matter, for the reasons I stated earlier, in that all references must have some form of definition before the compiler sees them. It does not matter what type of program (executable, COM component, DLL or static library) you are building, the rules are exactly the same for the language compilation phase.

            V 1 Reply Last reply
            0
            • L Lost User

              Vaclav_Sal wrote:

              I would like to do same in simple ( empty ) DLL

              As I said before, header files have nothing to do with DLLs. The reason for using StdAfx.h in a project is merely to speed up the compilation phase since all the preprocessing of the header files is done once and then saved in internal format that the compiler can quickly read. You can use exactly the same thing in a project that is to create a DLL. And the sequence of headers does matter, for the reasons I stated earlier, in that all references must have some form of definition before the compiler sees them. It does not matter what type of program (executable, COM component, DLL or static library) you are building, the rules are exactly the same for the language compilation phase.

              V Offline
              V Offline
              Vaclav_
              wrote on last edited by
              #6

              OK, this is a no code , empty, no MFC, no export / import etc. DLL. It is, or hopefully will be, a DirectShow filter. There are tons of DirectShow resources on how to build a graph and how to build a filter. I have not found a single source which actually explains HOW such DLL works / interacts with application , even GraphEdit. When I get it to compile (!) I will analyze it. My problem now is that #ifndef / #define / #endif DOES NOT work building this simple DLL. I am using same setup in all my MFC applications without a hitch. It theory it should work, but it does not. I suppose I could put all the code in one cpp / header and complile it that way. The block of common includes gets compiled multiple times. In each header file.I use #pragma message to track the compilation, and than the linker goes crazy. Either my VC6.0 finallly broke or I am missing something in setup / configuration of this DLL. At present I cannot risk, again, to use newer VS, last time I did that it messed up big time rebuilding my old MFC code without asking.

              L 1 Reply Last reply
              0
              • V Vaclav_

                OK, this is a no code , empty, no MFC, no export / import etc. DLL. It is, or hopefully will be, a DirectShow filter. There are tons of DirectShow resources on how to build a graph and how to build a filter. I have not found a single source which actually explains HOW such DLL works / interacts with application , even GraphEdit. When I get it to compile (!) I will analyze it. My problem now is that #ifndef / #define / #endif DOES NOT work building this simple DLL. I am using same setup in all my MFC applications without a hitch. It theory it should work, but it does not. I suppose I could put all the code in one cpp / header and complile it that way. The block of common includes gets compiled multiple times. In each header file.I use #pragma message to track the compilation, and than the linker goes crazy. Either my VC6.0 finallly broke or I am missing something in setup / configuration of this DLL. At present I cannot risk, again, to use newer VS, last time I did that it messed up big time rebuilding my old MFC code without asking.

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

                Vaclav_Sal wrote:

                My problem now is that #ifndef / #define / #endif DOES NOT work building this simple DLL.

                Because (I'm sorry to belabour this point) those directives have nothing to do with the program being a DLL. They are used by the compiler to include or exclude some sections of source code, in a compilation module.

                Vaclav_Sal wrote:

                I use #pragma message to track the compilation,   and than the linker goes crazy.

                That hardly tells us anything useful. You really need to show us some of the source code (and please use <pre> tags around it) and indicate what errors occur and where.

                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