Compiling MongoDB C++ driver on Cygwin

2019-08-12 07:16发布

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条回答
甜甜的少女心
2楼-- · 2019-08-12 07:55

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
查看更多
登录 后发表回答