# [C++] Common way to release code that supports multiple 3rd party dependencies

## Recommended Posts

I recently made me some makefiles for my library, as it is one of the most common ways to compile code. I will also include vcproj files (btw, which VS version do you suggest I use to generate vcproj files that can be opened by as many as possible VS versions?) and CodeBlock project files. Anyways, the library supports multiple 3rd party libraries, but are not all of them required! For instance, I can use Corona to load image files, or DevIL. When other people will compile the library, they probably don't want to first download and compile ALL supported 3rd party libs, but only the one's they use. Is there a common way to not compile certain source files (one's which implement 3rd party code)? Should this be done with macro's? Or do you think it is convenient enough to simply let the one compiling the lib not include the source files that require the 3rd party libs he has not? Thanks for the advice

##### Share on other sites
You could do conditional includes of CPP files in a CPP file that actually gets built.
//ImageLoading.cpp or something//this file gets compiled by the build system#ifdef USE_DEVIL#include "DevILImplementation.cpp" //this is only compiled it it's included here#endif#ifdef USE_CORONA#include "CoronaImplementation.cpp" //ditto#endif

Then #define USE_DEVIL or whatever on the command line. This might be a horrible kludge, but it's flexible and cross-platform (I think).

##### Share on other sites
What theOcelot mentioned is probably the easiest approach. Instead of using the command line, you could have a setup.h file where the user can turn on and off the different implementations.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628282
• Total Posts
2981811

• 9
• 10
• 11
• 17
• 15