Build C dll three ways based on a #define

Andy 41 Reputation points
2020-09-26T15:28:39.077+00:00

I have a C dll in a Visual Studio project that contains #define LEVEL taking value 0, 1, or 2. I build the dll one of these three ways and run a VB program that uses it. All of that works fine.

What I would like to do is build the dll all three ways from Visual Studio. I want to edit my source files and change dll project properties, and then build the 3 dlls respecting all changes. The 3 builds should be identical except for the value of the #define and the name and/or location of the output .dll file.

I don't see a simple way to do this. Any ideas?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,692 questions
0 comments No comments
{count} votes

4 additional answers

Sort by: Most helpful
  1. David Lowndes 4,711 Reputation points
    2020-09-26T15:56:47.417+00:00

    Create different build configurations. Use Build, Configuration Manager, select the project configuration combo box - and there you can create alternate configurations with different settings.

    0 comments No comments

  2. Andy 41 Reputation points
    2020-09-26T16:16:00.467+00:00

    Under Build, Configuration Manager, I don't see a project configuration combo box.
    I see active solution configuration, active solution platform, and project contexts.
    My only config is Release, my only platform is x64, and everything looks correct.
    I'm running VS 2017 community edition - is that a problem?

    0 comments No comments

  3. Andy 41 Reputation points
    2020-09-26T17:39:04.62+00:00

    I'm most of the way there. I've defined configs Level1 and Level2. Each defines preprocessor variables and properly builds dlls in their own directories. So, with Release, Level1, and Level2, I have my three dlls.

    Level1 and Level2 inherit properties from Release. If I change a property in the Release configuration, will it apply to Level1 and Level2? Or have I opened the can of worms of keeping three sets of properties in sync?

    Is there a way to build all configurations at once?


  4. Andy 41 Reputation points
    2020-09-26T20:30:10.563+00:00

    I think I've got it all, I'll post a new issue in a day or so if further problem in this area. But I think I see it all now. In the past, all I did was a couple of release executables and mostly compiled and ran in the ide in debug mode. Little experience with more complex build questions. Thanks a million!

    0 comments No comments

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.