VS2019 x64 dll project build issues with mongo-cxx-driver-r3.8.0

Hi

I followed Getting Started with MongoDB and C++ | MongoDB
I have built the following correctly on windows 10.

  1. mongo-cxx-driver-r3.8.0
  2. mongo-c-driver-1.24.1
  3. boost_1_82_0

and I have all libs available now,

  1. mongocxx.lib
  2. bsoncxx.lib
  3. bson-1.0.lib
  4. bson-static-1.0.lib
  5. mongoc-1.0.lib
  6. mongoc-static-1.0.lib
  7. libboost_system-vc142-mt-gd-x64-1_82.lib
  8. libboost_filesystem-vc142-mt-gd-x64-1_82.lib
  9. libboost_thread-vc142-mt-gd-x64-1_82.lib
  10. libboost_date_time-vc142-mt-gd-x64-1_82.lib

Now I need to use Mongo DB c++ in the VS2019 x64 DLL project, I have all C++ include paths and lib paths and libs in linker when I include #include <mongocxx/client.hpp>
in my cpp file and building the project, I get many errors. look like this is only for a DLL project. is there any macro to define in the preprocessor? I already tried MONGOCXX_EXPORTS but still, the same errors appeared …

very 1st error

    create_collection_deprecated& max(std::int64_t max_documents)
Error (active)	E0106	invalid type for a bit field	DataBase	103		libs\mongo-cxx-driver-r3.8.0\src\mongocxx\options\create_collection.hpp
 find& max(bsoncxx::document::view_or_value max)
Error	C2146	syntax error: missing ')' before identifier 'max'	DataBase	301
\libs\mongo-cxx-driver-r3.8.0\src\mongocxx\options\find.hpp

I get errors in

  1. find_one_and_delete.hpp
  2. find_one_and_replace.hpp
  3. delete.hpp
  4. insert_many.hpp
  5. replace_one.hpp
  6. update.hpp
  7. collection.hpp

I guess the same issue is mentioned on another topic Can build console app with mongocxx but not DLL project VS2019

Hi @Galaxy_Core,

You may be colliding with the windows min and max macros.
What happens if you add #define NOMINMAX before #include <windows.h> in your code? Does the problem go away?

See this article for reference - The min/max problem in C++ and Windows

1 Like