我按照指示为MongoDB C Driver(版本1.9.2)构建静态库http://mongoc.org/libmongoc/current/installing.html。它安装正确,可以构建示例
gcc -o hello_mongoc hello_mongoc.c $(pkg-config --libs --cflags libmongoc-static-1.0)
接下来我想要一个mongcxx静态库。我在Ubuntu 16.04上做了这些步骤 如下所示:静态mongo c驱动程序安装后的https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/
git clone https://github.com/mongodb/mongo-cxx-driver.git \ - 分支发布/稳定 - 深度1 cd mongo-cxx-driver / build
cmake -DBUILD_SHARED_LIBS = OFF -DCMAKE_BUILD_TYPE =发布-DCMAKE_INSTALL_PREFIX = / usr / local ..
sudo make EP_mnmlstc_core
make&& sudo make install
现在我尝试运行示例程序
roshan@bolt:~$ c++ --std=c++11 test.cpp $(pkg-config --cflags --libs libmongocxx-static)
Package libmongocxx-static was not found in the pkg-config search path.
Perhaps you should add the directory containing `libmongocxx-static.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libmongocxx-static' found
test.cpp:3:47: fatal error: bsoncxx/builder/stream/document.hpp: No such file or directory
compilation terminated.
和
roshan@bolt:~$ pkg-config --cflags libmongocxx-static
Package libmongocxx-static was not found in the pkg-config search path.
Perhaps you should add the directory containing `libmongocxx-static.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libmongocxx-static' found
另外,我注意到了:
/usr/local/lib/libmongocxx.a正在sudo make install之后创建,但不是libmongocxx-static。
完成所有这些步骤后:
roshan@bolt:/usr/local/lib$ ls
cmake libbson-1.0.so.0.0.0 libmongoc-1.0.so ocaml
libbson-1.0.a libbsoncxx.a libmongoc-1.0.so.0 pkgconfig
libbson-1.0.la libbson-static-1.0.a libmongoc-1.0.so.0.0.0 python2.7
libbson-1.0.so libmongoc-1.0.a libmongoc-static-1.0.a python3.5
libbson-1.0.so.0 libmongoc-1.0.la libmongocxx.a
答案 0 :(得分:0)
我不确定为什么要这样做,但是文档已更新,以反映当前版本/稳定分支上尚不存在的主数据库更改。添加-static版本的mongocxx软件包的工作发生在v3.1分支(其中发布/稳定当前点)被拉动之后的主分支上。
当您查看r3.2.0-rc1标签时,您能看到上述过程是否适合您?希望我们很快就会发布r3.2.0,所以最好确认它对您有用。