1

我正在尝试在 Windows 上编译 MongoDB C++ 驱动程序。我正在使用 SCons“制作”工具。它给了我一个 Boost 错误,我有引导库,但我不确定如何让它与 SCons 构建文件链接。我习惯于在 VS 中添加引用。看起来我需要一个环境变量引用,但我不确定。

这是错误:

scons mongoclient
scons: Reading SConscript files ...
Checking for C++ library boost_thread-mt... (cached) no
Checking for C++ library boost_thread... (cached) no
Checking for C++ library boost_filesystem-mt... (cached) no
Checking for C++ library boost_filesystem... (cached) no
Checking for C++ library boost_system-mt... (cached) no
Checking for C++ library boost_system... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
cl /Fobuild\mongo\bson\oid.obj /c src\mongo\bson\oid.cpp /TP /nologo /EHsc /O2 /
D_SCONS /DMONGO_EXPOSE_MACROS /Ibuild /Isrc /Ibuild\mongo /Isrc\mongo
oid.cpp
src\mongo/pch.h(48) : fatal error C1083: Cannot open include file: 'boost/shared
_ptr.hpp': No such file or directory
scons: *** [build\mongo\bson\oid.obj] Error 2
scons: building terminated because of errors.

在 SConstruct 文件中,我找到以下内容,但不确定查找 boost 库的确切含义。

boostLibs = ["thread", "filesystem", "system"]
conf = Configure(env)
for lib in boostLibs:
    if not conf.CheckLib(["boost_%s-mt" % lib, "boost_%s" % lib],
                         language="C++"):
        if not win:
            Exit(1)
conf.Finish()
4

2 回答 2

2

所以我终于能够通过发现这个来提升 Libs 的出现:

scons --extrapath=c:\boost

C:\boost 是 boost 的目录。我现在遇到编译器错误,但这比以前更严重。

于 2013-03-17T18:40:18.750 回答
0

您可以使用 --cpppath 选项添加其他包含路径

--cpppath : Include path if you have headers in a nonstandard directory

此外,请记住编译您的引导库并链接到包含 boost 库 .lib 文件的正确文件夹

--libpath : Library path if you have libraries in a nonstandard directory

因此,您应该发出类似于以下的命令:

scons --cpppath=c:\boost --libpath=c:\boost\stage\lib
于 2014-07-11T13:43:37.523 回答