The Hell that is Visual C/C++ Libraries
I’m working on a project that is a C++ library. Our main target platform is Windows using Microsoft Visual C++. As far as I know, there is no standard directory to put headers and libraries, and there is no naming convention for the library files themselves to help deal with runtime linking hell.
Without a standard directory, how should we do a binary release? Should we have the installer put them in C:\Program Files\<project>\? Or just C:\<project>\? Or do we just release a zip file, and let user unzip this wherever they want? Or both?
The runtime linking hell is an issue that resolves around these compiler flags: /ML, /MT, /MD, /MLd, /MTd, /MDd. These determine which C and C++ runtime library your code links against. And you must compile your code and all dependent libraries with the same flag or you are sure to get linker errors. So, ideally, we should distribute 6 variants of our library to make all possible users happy, and not require compiling our code. But again, where is it documented how I should do this? There is no standard naming convention.
For some good ideas and possible solutions, there are two good articles on GameDev.net: Static Library Tips and Making Your Libraries Release-Friendly. Granted there is still no standard, but it is quite useful information.
And while I’m at it, Unix and Mac OS X have their share of problems with libraries, too. OS X is the most advanced due to its frameworks, but it also inherits some bad habits from its Unix underpinnings. More on this in a later post, I think.