Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-11325

mongoclient fails to compile with Visual C++ 2008 SP1

    • Windows
    • Hide

      Just issue the command:

      scons mongoclient --release --use-system-boost --cpppath="C:\Program Files\Boost\boost_1_46_1" --libpath="C:\Program Files\Boost\boost_1_46_1\lib" --boost-compiler=vc90 --boost-version=1_46_1
      

      Result:

      scons: Reading SConscript files ...
      scons version: 2.3.0
      python version: 2 7 3 'final' 0
      found visual studio at c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
      Windows SDK Root 'C:/Program Files/Microsoft SDKs/Windows/v6.0a'
      Checking whether the C++ compiler works(cached) yes
      Checking for C++ header file boost/filesystem/operations.hpp... (cached) yes
      Checking for C++ library boost_thread-vc90-mt-1_46_1... (cached) yes
      Checking for C++ library boost_filesystem-vc90-mt-1_46_1... (cached) yes
      Checking for C++ library boost_program_options-vc90-mt-1_46_1... (cached) yes
      Checking for C++ library boost_system-vc90-mt-1_46_1... (cached) yes
      Checking for C header file unistd.h... (cached) no
      Checking whether clock_gettime is declared... (cached) no
      Checking for C++ header file execinfo.h... (cached) no
      Checking for C library pcap... (cached) no
      Checking for C library wpcap... (cached) no
      scons: done reading SConscript files.
      scons: Building targets ...
      ...
      C:\lib\mongodb\mongo\src\mongo/platform/cstdint.h(24) : fatal error C1083: Cannot open include file: 'cstdint': No such file or directory
      scons: *** [build\win32\cpppath_C__Program Files_Boost_boost_1_46_1\libpath_C__P rogram
      Files_Boost_boost_1_46_1_lib\release\use-system-boost\client_build\mongo\base\parse_number.obj] Error 2
      scons: building terminated because of errors.
      

      One possible (ugly) workaround:

      1. Use https://code.google.com/p/msinttypes/
      2. Modify src\mongo\platform\cstdint.h in the following way:
        ...
        #if defined(_MSC_VER)
        #include <stdint.h>
        #define _MONGO_STDINT_NAMESPACE
        #elif defined(__GNUC__)
        ...
        


      Next, there are 2 undefined macros in src\mongo\util\net\listen.cpp: EADDRINUSE and ECONNABORTED. Both of them were added to errno.h in Visual C++ 2010. But they must be defined for 2008.

      Quick and very dirty workaround: modify src\mongo\util\net\listen.cpp in the following way:

      ...
      #undef errno
      #define errno WSAGetLastError()
      #define EADDRINUSE   100
      #define ECONNABORTED 106
      
      #endif
      
      namespace mongo {
      ...
      

      By fixing these two issues, the c++ driver can be compiled successfully.

      Show
      Just issue the command: scons mongoclient --release --use-system-boost --cpppath="C:\Program Files\Boost\boost_1_46_1" --libpath="C:\Program Files\Boost\boost_1_46_1\lib" --boost-compiler=vc90 --boost-version=1_46_1 Result: scons: Reading SConscript files ... scons version: 2.3.0 python version: 2 7 3 'final' 0 found visual studio at c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN Windows SDK Root 'C:/Program Files/Microsoft SDKs/Windows/v6.0a' Checking whether the C++ compiler works(cached) yes Checking for C++ header file boost/filesystem/operations.hpp... (cached) yes Checking for C++ library boost_thread-vc90-mt-1_46_1... (cached) yes Checking for C++ library boost_filesystem-vc90-mt-1_46_1... (cached) yes Checking for C++ library boost_program_options-vc90-mt-1_46_1... (cached) yes Checking for C++ library boost_system-vc90-mt-1_46_1... (cached) yes Checking for C header file unistd.h... (cached) no Checking whether clock_gettime is declared... (cached) no Checking for C++ header file execinfo.h... (cached) no Checking for C library pcap... (cached) no Checking for C library wpcap... (cached) no scons: done reading SConscript files. scons: Building targets ... ... C:\lib\mongodb\mongo\src\mongo/platform/cstdint.h(24) : fatal error C1083: Cannot open include file: 'cstdint': No such file or directory scons: *** [build\win32\cpppath_C__Program Files_Boost_boost_1_46_1\libpath_C__P rogram Files_Boost_boost_1_46_1_lib\release\use-system-boost\client_build\mongo\base\parse_number.obj] Error 2 scons: building terminated because of errors. One possible (ugly) workaround: Use https://code.google.com/p/msinttypes/ Modify src\mongo\platform\cstdint.h in the following way: ... #if defined(_MSC_VER) #include <stdint.h> #define _MONGO_STDINT_NAMESPACE #elif defined(__GNUC__) ... Next, there are 2 undefined macros in src\mongo\util\net\listen.cpp : EADDRINUSE and ECONNABORTED . Both of them were added to errno.h in Visual C++ 2010. But they must be defined for 2008. Quick and very dirty workaround: modify src\mongo\util\net\listen.cpp in the following way: ... #undef errno #define errno WSAGetLastError() #define EADDRINUSE 100 #define ECONNABORTED 106 #endif namespace mongo { ... By fixing these two issues, the c++ driver can be compiled successfully.

      The mongoclient c++ library does not compile with Visual C++ 2008.

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            bszente Balint Szente
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: