It looks like the libsasl2 port for Windows is not complete. Although I eventually got libsasl to compile, libsasl2 was not created. It looks like SASL is used by MongoDB C Driver for Kerberos. I do not know if they tried to get Kerberos to work with the C-driver on Windows without the libsasl2 library port.
However, I was able to eventually compile the MongoDB C driver. At first I tried to compile using the C: \ subdirectories, unlike C: \ mongo-c-driver, etc., but this did not work, but when I compiled Using the directory structure in the documentation, compilation was successful.
To compile it, I disabled the SASL library in compilation. I do not think this will be necessary if you do not need to use Kerberos. At first I had to explicitly disable SASL (perhaps due to the use of 64-bit) - this can be done using -DENABLE_SASL=no when compiling the mongo-c driver.
Here are the steps:
Using this page you can find the source of the drivers: https://github.com/mongodb/mongo-c-driver/releases (1.3.5)
Got cmake from https://cmake.org/download/
Installed cmake using the Windows installer, adding cmake to the path for all users. I had to log out and log in to get the upgrade path.
Then I copied the source mongo-c-driver-1.3.5 to c: \ mongo-c-driver-1.3.5
Then
I used the Visual Studio MSBuild command line starting with Run As Administrator
C:\mongo-c-driver-1.3.5\src\libbson>cmake -DCMAKE_INSTALL_PREFIX=C:\libmongoc -G "Visual Studio 14" -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:3 (project): No CMAKE_C_COMPILER could be found. CMake Error at CMakeLists.txt:3 (project): No CMAKE_CXX_COMPILER could be found. -- Configuring incomplete, errors occurred! See also "C:/mongo-c-driver-1.3.5/src/libbson/CMakeFiles/CMakeOutput.log". See also "C:/mongo-c-driver-1.3.5/src/libbson/CMakeFiles/CMakeError.log".
It turns out that C compilers are not installed with a standard Visual Studio installation, so I had to install the C ++ Visual Studio component. I installed C ++ Common Tools, but not MFC for C ++ and XP. However, it will use 3 GB of disk space (started at 39.5, ended at 37.0, so 2.5 GB was used).
Once it has been installed:
cd \mongo-c-driver-1.3.5\src\libbson cmake -DCMAKE_INSTALL_PREFIX=C:\libmongoc -G "Visual Studio 14" . msbuild.exe ALL_BUILD.vcxproj msbuild.exe INSTALL.vcxproj cd ..\.. C:\mongo-c-driver-1.3.5>cmake -DCMAKE_INSTALL_PREFIX=C:\libmongoc -DENABLE_SSL=WINDOWS -DBSON_ROOT_DIR=C:\libmongoc -G "Visual Studio 14" . -- The C compiler identification is MSVC 19.0.23026.0 -- The CXX compiler identification is MSVC 19.0.23026.0 -- Check for working C compiler using: Visual Studio 14 2015 -- Check for working C compiler using: Visual Studio 14 2015 -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler using: Visual Studio 14 2015 -- Check for working CXX compiler using: Visual Studio 14 2015 -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found BSON: C:/libmongoc/lib/bson-1.0.lib;ws2_32 -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) -- Searching for sasl/sasl.h -- Not found (specify -DCMAKE_INCLUDE_PATH=C:/path/to/sasl/include for SASL support) -- Searching for libsasl2 -- Not found (specify -DCMAKE_LIBRARY_PATH=C:/path/to/sasl/lib for SASL support) Current version (from VERSION_CURRENT file): 1.3.5 -- Configuring done -- Generating done -- Build files have been written to: C:/mongo-c-driver-1.3.5
OpenSSL was not present, so I got the 32-bit Win32 OpenSSL v1.0.2h from http://slproweb.com/products/Win32OpenSSL.html
Then I installed OpenSSL. Changed the installation directory to C: \ work \ OpenSSL-Win32, and I allowed the OpenSSL installer to install the binaries in the Windows system directory
Now,
C:\mongo-c-driver-1.3.5>cmake -DCMAKE_INSTALL_PREFIX=C:\libmongoc -DENABLE_SSL=WINDOWS -DBSON_ROOT_DIR=C:\libmongoc -G "Visual Studio 14" . -- Found OpenSSL: optimized;C:/work/OpenSSL-Win32/lib/VC/ssleay32MD.lib;debug;C:/work/OpenSSL-Win32/lib/VC/ssleay32MDd.lib;optimized;C:/work/OpenSSL-Win32/lib/VC/libeay32MD.lib;debug;C:/work/OpenSSL-Win32/lib/VC/libeay32MDd.lib (found version "1.0.2h") -- Searching for sasl/sasl.h -- Not found (specify -DCMAKE_INCLUDE_PATH=C:/path/to/sasl/include for SASL support) -- Searching for libsasl2 -- Not found (specify -DCMAKE_LIBRARY_PATH=C:/path/to/sasl/lib for SASL support) Current version (from VERSION_CURRENT file): 1.3.5 -- Configuring done -- Generating done -- Build files have been written to: C:/mongo-c-driver-1.3.5 C:\mongo-c-driver-1.3.5> msbuild.exe ALL_BUILD.vcxproj (lots of output, with some yellow warnings, but no red errors) msbuild.exe INSTALL.vcxproj
And now the mongo-c-driver is built. I can use it with Visual C ++ to connect to my MongoDB server using ssl.
Now I'm trying to figure out how to get Embarcadero RADStudio C ++ Builder to use the new mongo-c driver. Just copying the .dll to the application folder leads to an interruption in the bson dll. The stack trace looks like this:
