OK i believe i found out what the issue was. It looks like by default, when compiling mongoc visual studio project “as is”, the output libs named static are not anyhow statically built.
To compile mongoc statically (MT) and embed the dependencies in my own dll, i had to compile libbson and libmongoc as well as their dependencies with MT too.
So here is my guide:
First, compile MT (C++ Code Generation) Versions of the sub projects from the visual studio project that contains all the mongoc examples and libs, namely: mpongoc_static and bson_static, you might need to compile their dependencies also as MT, e.g. zlib and i believe utf8proc_obj.
My successful linker dependencies look like this:
$(ProjectDir)Dependencies\mongo-c-driver\lib\MT\Release\bson-static-1.0.lib
$(ProjectDir)Dependencies\mongo-c-driver\lib\MT\Release\mongoc-static-1.0.lib
ws2_32.lib
Secur32.lib
Crypt32.lib
BCrypt.lib
DnsAPI.Lib
This way, my project compiled successfully without dependent dll’s But there were lots of warnings. To get rid of these warnings, i had to add to Linker/Commandline:
/NODEFAULTLIB:MSVCRTD (or /NODEFAULTLIB:MSVCRT for release)
If you still get warnings like LNK4286, ensure that you include mongoc.h only once in the whole project and use the define BSON_STATIC, which changes decldir to cdecl.
#define BSON_STATIC
#define MONGOC_STATIC
#include <mongoc/mongoc.h>