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. Custom build

Custom build

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestionannouncement
5 Posts 3 Posters 0 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.
  • 0 Offline
    0 Offline
    0v3rloader
    wrote on last edited by
    #1

    Hello, I have a Lib which has some objects which are compiled depending on whether certain macros are defined or not. I was wondering if it is possible to have multiple builds of the Lib for the different scenarios and have Visual C++ automatically choose between the correct version of the Lib to use? Example:

    In the Lib:
    #ifdef _MACROA
    class A
    {
    .
    :
    .
    };
    #endif // defined(_MACROA)

    This means that we have two possible versions of the Lib: one for when _MACROA is defined and another for when it's not. So the question is how to configure the project settings in the (implementation) App - if such a thing is possible at all - to make it choose the correct version of the Lib depending on whether the macro is defined or not. Perhaps I should adopt a different strategy? All insights on the question in hand will be greatly appreciated. David

    R B 2 Replies Last reply
    0
    • 0 0v3rloader

      Hello, I have a Lib which has some objects which are compiled depending on whether certain macros are defined or not. I was wondering if it is possible to have multiple builds of the Lib for the different scenarios and have Visual C++ automatically choose between the correct version of the Lib to use? Example:

      In the Lib:
      #ifdef _MACROA
      class A
      {
      .
      :
      .
      };
      #endif // defined(_MACROA)

      This means that we have two possible versions of the Lib: one for when _MACROA is defined and another for when it's not. So the question is how to configure the project settings in the (implementation) App - if such a thing is possible at all - to make it choose the correct version of the Lib depending on whether the macro is defined or not. Perhaps I should adopt a different strategy? All insights on the question in hand will be greatly appreciated. David

      R Offline
      R Offline
      RChin
      wrote on last edited by
      #2

      You could use a method such as:#ifdef _DEBUG #pragma comment(lib,"SomeLibrary_D.lib") // Use debug build of library #else #pragma comment(lib,"SomeLibrary.lib") // Use release build of library #endif
      Depending on which build of your program you will be using, these #pragma definitions will use the corresponding build of the dependent dll.


      I Dream of Absolute Zero

      1 Reply Last reply
      0
      • 0 0v3rloader

        Hello, I have a Lib which has some objects which are compiled depending on whether certain macros are defined or not. I was wondering if it is possible to have multiple builds of the Lib for the different scenarios and have Visual C++ automatically choose between the correct version of the Lib to use? Example:

        In the Lib:
        #ifdef _MACROA
        class A
        {
        .
        :
        .
        };
        #endif // defined(_MACROA)

        This means that we have two possible versions of the Lib: one for when _MACROA is defined and another for when it's not. So the question is how to configure the project settings in the (implementation) App - if such a thing is possible at all - to make it choose the correct version of the Lib depending on whether the macro is defined or not. Perhaps I should adopt a different strategy? All insights on the question in hand will be greatly appreciated. David

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        You could also always add a new 'configuration'. The 2 defaults are Win32 Release and Win32 Debug, but you can add others, which allows you to define specific project settings for each one. You can create different output files, use different preprocessor macros, include different libraries, etc. You you could have Win32 Release With MacroA Win32 Release No MacroA Win32 Debug With MAcroA Win32 Debug No MAcroA for example. On the VC 6.0 'Build' menu there is an item labeled 'Configurations...' that invokes a dialog that allows you to add/remove configurations. Then, when you want to work on a specific configuration, you use the Build|Set Active Configuraiton... menu item to specifically define the one you are working on. You can use Build|Batch Build... menu item to make all of them at once.

        0 1 Reply Last reply
        0
        • B Blake Miller

          You could also always add a new 'configuration'. The 2 defaults are Win32 Release and Win32 Debug, but you can add others, which allows you to define specific project settings for each one. You can create different output files, use different preprocessor macros, include different libraries, etc. You you could have Win32 Release With MacroA Win32 Release No MacroA Win32 Debug With MAcroA Win32 Debug No MAcroA for example. On the VC 6.0 'Build' menu there is an item labeled 'Configurations...' that invokes a dialog that allows you to add/remove configurations. Then, when you want to work on a specific configuration, you use the Build|Set Active Configuraiton... menu item to specifically define the one you are working on. You can use Build|Batch Build... menu item to make all of them at once.

          0 Offline
          0 Offline
          0v3rloader
          wrote on last edited by
          #4

          Great! That's exactly what I was looking for! Thank you very much for replying. David

          B 1 Reply Last reply
          0
          • 0 0v3rloader

            Great! That's exactly what I was looking for! Thank you very much for replying. David

            B Offline
            B Offline
            Blake Miller
            wrote on last edited by
            #5

            You are welcome, glad the information helped. It is a handy feature to make custom builds of your software for different customers or target audiances.

            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