在Cygwin上编译MongoDB c++驱动程序

Compiling MongoDB C++ driver on Cygwin

本文关键字:c++ 驱动程序 MongoDB 编译 Cygwin      更新时间:2023-10-16

我试图用'scons'命令在Cygwin上编译MongoDB c++驱动程序,我得到以下错误:

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

那是什么lib ?

谢谢。

srandomdev函数在BSD或OSX系统的stdlib.h中可用,而在GNU系统如Cygwin或Linux上不可用。

看起来构建脚本无法识别您在Cygwin上运行的事实。有几个选择你可以尝试一下。最简单的是

修改ifdef子句

如果没有Windows机器来测试,很难确认这是否适用于您。在src/mongo/platform/random.cpp中,编辑第108行

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

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

删除最后一个else子句

找到src/mongo/platform/random.cpp看起来像

的那行(在我的版本中是141)
#else
class SRandSecureRandom : public SecureRandom {
public:

删除#endif子句下面的行,然后编辑

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

就是

#else