I'm trying to create a c++ library for use on windows/MSVC.
My problem is that it seems that in order to link properly, I need to distribute a bunch of different versions, linked against different versions of MSVC's c++ runtimes - single and multi-threaded, debug and release, different compiler versions, various other security and other options.
I'd love to just distribute maybe two, 32 bit and 64 bit.
My idea is to maybe use a different new operator (say, mynew) and custom allocators for all my STL types. When creating the lib, /nodefaultlib. Then, when linking in from a parent project, require them to thunk mynew to new, and my stl allocator to the standard one (or one of their choosing). I guess I'd need to do delete, and a few other functions. Naturally I'd provide an example thunking implementation with the library, but this would hopefully save everyone a lot of headache.
Is this possible? Has anyone ever tried this? Is there a best practices for library creation/distribution on windows/MSVC?
You want static linking, as a general answer.
Quick note on Chris' answer (don't want to de-boost cause it's mostly good, but...):
DO NOT link to msvcrt.dll (the unversioned one); this is the OS-specific version DLL, and if you link to it, your app probably will not work on other versions of Windows. You should always be linking to msvcrt##.dll, as far as I know. The DDK may contain a lib for it, but don't link to it unless you really know what you're doing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With