Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi,

I am developing ActiveX control using VC++ with Visual Studio 2010, on WindowsXP.

I want to have multiple release types for my project. The release types will differ in features. The release A may have only features A1...An while Release B may have only features B1....Bn. Also, there are third-party libraries being used in project. A particular release will only consider libraries relevant to its features.

How can this be achieved? Is it possible to introduce conditions thru macros or any other mechanism, into build so that particular release builds only limited set of features?

Regards,
Rajesh G Manwani
Posted

Macros are compile-time features, not runtime features.

One way to accomplish this would be to include one or more DLLs in your project that turn one various features, and then base those features' availablity on the presence or absence of the DLLs.

Of course, there are many other ways, but this one is probably the simplest to implement.
 
Share this answer
 
v2
One way is like that:

a) Create One Function InitializeComponent(Key)

// Key is passed as argument.
For Different client, the key is different
For Client 'A' it is 3123123
For Client 'B' it is 2343454

b)Client must use this function.

c) Check the key value is correct.

c) According to that key only feature is available to client.
 
Share this answer
 
Comments
Dalek Dave 8-Dec-10 3:52am    
Good Call.
Hi Rajesh,
Use the Visual Studio Configuration Manager (in Build menu) to create different project configurations, see How to: Create and Edit Configurations[^].
Use compile time definitions to adjust specific configuration features.
cheers,
AR
 
Share this answer
 
v2
This is a large topic and there are many considerations. For example, at one extreme you can have one executable and use run-time flags to control which features are seen. At the other extreme you can create different release configurations (see below) that define macros (for conditional compilation) and only link to the relevant libraries.

The advantage of the first method is that the development, build and distribution process is simplified. The disadvantage is in efficiency (a larger distribution and probably more memory use etc).

The advantage of the second is that each release is close to the optimum for its requirement. However, if there are many differences then the conditional compilation can make the source code a mess.

In practice you will probably use a compromise between these two extremes. For example, you could create a simple "plugin" system where different plugins (DLLs) are only used if present - as someone else already suggested.

Another alternative is to use inheritance where the core system consists of many base classes with virtual "hook" functions. Variations of the product could use different derived classes to override the virtual functions to provide different behaviours.

Configurations

By default Visual Studio only creates two configurations (Debug and Release), but you can use the Configurations manager to create extra release configurations by cloning the existing release config. Then you can use the Properties pages to define preprocessor flags (C/C++ -> Preprocessor -> Preprocessor Defintions) that can control your compilation, and change which libraries you link with (Link -> Input -> Additional Dependencies).
 
Share this answer
 
Comments
Dalek Dave 8-Dec-10 3:51am    
Good Answer.
Thank you all for your response.

I have read each of the solutions and admire the knowledge exhibhited in each of them.

All the solutions are genuine and feasible. I think that making different Visual Studio Configurations will be sufficient for my needs
and I will try this. If it does not work, I may evaluate other solutions.
 
Share this answer
 
In a VS2010 project, I created a new configuration C2 copying settings from C1. The purpose of having new configuration was to do conditional compiling. I thought I can achieve it thru different peprocessors. But I found that when I define a processor in either C1 or C2, it gets reflected in both C1 & C2. How this can be stopped? Can different configurations have different preprocessor defintion? or there is some different mechanism to achieve it?
 
Share this answer
 
Comments
Estys 5-Feb-11 6:28am    
If I were you, I would make this a new question. AFAIK you cannot do this with VS. A suggestion : google for "MSBuild" and "Nant".
Something else to consider is to make sure that the target machine has the version of .NET installed that you are targeting with your VS2010 project.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900