c++ two resources for different build (how to?)

Code Wanderer 396 Reputation points
2020-10-01T12:19:11.197+00:00

I have project where I have resources and for debug version I need different resources files (because I have included dll as resources).

Now when I compile application, it include all dlls (debug and release dlls), how to specify the compiler to include only debug or release dlls (depends on build settings)?

I tried click on dll and properties > (Debug) > Excluded From Build : Yes, Content : No
but it doesnt help.

I have created two resource files (*.rs) one for debug and second for reslease and set release rs to exclude from build it doesn't help.

Developer technologies | C++
Developer technologies | Visual Studio | Other
{count} votes

Accepted answer
  1. Viorel 122.6K Reputation points
    2020-10-01T13:54:15.797+00:00

    If you select a resource in Resource View (e.g. a dialog) and go to Properties (press <F4>), you will see an input field called “Condition”, where you can type the preprocessor symbol that determines the inclusion of the resource.

    Maybe this technique can be used in your case. Use these symbols: _DEBUG and NDEBUG. What type of resource do you have?


1 additional answer

Sort by: Most helpful
  1. RLWA32 49,551 Reputation points
    2020-10-01T14:31:16.607+00:00

    To include entire .rc files based on debug or release you can try this -

    Add the separate .rc files for debug and release versions to the dll project and configure their properties to exclude them from both release and debug builds.

    29618-solution.png

    In the dll projects main .rc add compile time preprocessor directives to #include either the debug .rc file or the release .rc file. See how-to-include-resources-at-compile-time
    29619-includes.png

    In the dll project properties go to the properties for the resource compiler and add _DEBUG
    29685-preprocessor.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.