Compiling MongoDB C++ driver on Cygwin

2019-08-12 07:26发布

问题:

I junt trying compile the MongoDB C++ driver on Cygwin with the 'scons' command and i getting this follow error:

src/mongo/db/nonce.cpp:48:20: error: ‘srandomdev’ was not declared in this scope

What lib is that?

Thanks.

回答1:

The srandomdev function is available in stdlib.h on BSD or OSX systems, not on GNU systems like Cygwin or Linux.

It looks like the build script does not recognize the fact that you are running on Cygwin. There are a few options that you can try. The easiest ones are

Change ifdef clause

Without a Windows machine to test this on, it is hard to confirm this will work for you. In src/mongo/platform/random.cpp , edit line 108

#elif defined(__linux__) || defined(__sunos__) || defined(__APPLE__)

to be

#elif defined(__linux__) || defined(__sunos__) || defined(__APPLE__) || defined(__CYGWIN__)

Delete the last else clause

Find the line (141 in my version) of src/mongo/platform/random.cpp that looks like

#else
class SRandSecureRandom : public SecureRandom {
public:

Delete the lines down to the #endif clause and then edit

#elif defined(__linux__) || defined(__sunos__) || defined(__APPLE__)

to simply be

#else