2

I'm trying to compile Mongo C++11 driver with MinGW (G++ 6.3.0) on Windows 10 64bit. From GCC 6 release notes;

The default mode has been changed to -std=gnu++14.

My understanding is that C++11 is also supported by default. Why then do I get these error message about mutex and thread?

from F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/exception/private/mongoc_error.hh:19,
from F:\Projects\Mongo\attempt_4_mingw64\mongo-cxx-driver-r3.1.1\src\mongocxx\bulk_write.cpp:20:
F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/test_util/mock.hh:183:10: error: 'mutex' in namespace 'std' does not name a type
         std::mutex _active_instances_lock;
              ^~~~~
F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/test_util/mock.hh:184:24: error: 'thread' is not a member of 'std'
         std::unordered_map<std::thread::id, instance*> _active_instances;
                            ^~~
F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/test_util/mock.hh:184:24: error: 'thread' is not a member of 'std'
F:/Projects/Mongo/attempt_4_mingw64/mongo-cxx-driver-r3.1.1/src/mongocxx/test_util/mock.hh:184:50: error: wrong number of template arguments (1, should be at least 2) 
         std::unordered_map<std::thread::id, instance*> _active_instances;
                                                      ^
Amani
  • 11,038
  • 16
  • 74
  • 118
  • 1
    Are you running a build-system which lets you see the commands that are executed? What flags are passed to the compiler? Can you perhaps show that too? Is the compiler used really the one you expect? – Some programmer dude Jun 15 '17 at 12:42
  • @Someprogrammerdude, I'm using CMake 3.8, and its gives this kind of output `-- Check for working CXX compiler: C:/MinGW64/bin/g++.exe -- works`. So for sure its using G++ and the only version I have is 6.3.0. – Amani Jun 15 '17 at 12:46
  • If you run `make VERBOSE=1` then you will see the flags passed to the compiler. Is something like `-std=c++03` (or similar) passed to the compiler? – Some programmer dude Jun 15 '17 at 12:48
  • see https://stackoverflow.com/questions/17242516/mingw-w64-threads-posix-vs-win32 – rogerdpack Oct 25 '18 at 06:10

1 Answers1

1

mongocxx currently only supports MSVC on Windows, so building with MinGW might not be possible. That being said, if you're not already, I suggest passing -std=c++11 in your CMAKE_CXX_FLAGS to see if that works.

Saghm
  • 201
  • 1
  • 4