如何在ubuntu安装mongodb驱动程序的c ++? [英] how to install mongodb drivers for c++ in ubuntu?

查看:169
本文介绍了如何在ubuntu安装mongodb驱动程序的c ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用c + + mongoDB开发一个相当简单的应用程序,我按照他们的教程:
http://www.mongodb.org/pages/viewpage.action?pageId=133415

I want to develop a fairly simple application using c++ for mongoDB and I follow their tutorials : http://www.mongodb.org/pages/viewpage.action?pageId=133415

和安装我所遵循的驱动程序这个:
https:// groups.google.com/forum/?fromgroups=#!msg/mongodb-user/-mPG7MDJgm8/nZSiN42DJWIJ
(Waitman Gobble / 5 jun answer)

and for installing driver I followed this one : https://groups.google.com/forum/?fromgroups=#!msg/mongodb-user/-mPG7MDJgm8/nZSiN42DJWIJ (Waitman Gobble/5 jun answer)

但是当我尝试编译一个简单的应用程序时,我会得到以下错误:

but yet when I try to compile a simple application I will get following error :


致命错误:client / dbclient.h :没有这样的文件或目录

fatal error: client/dbclient.h: No such file or directory

我很确定问题是MongoDB c ++驱动程序尚未安装。

I'm pretty sure the problem is MongoDB c++ driver hasn't installed yet.

如何正确安装?

推荐答案

如果您下载驱动程序源代码从这里

If you download the driver source code from here,

解压和解压缩

tar xzf mongodb-linux-x86_64-v2.0-latest.tgz 

然后cd进入目录。

cd mongo-cxx-driver-v2.0/

然后使用scons建立

Then use scons to build

scons

并安装

sudo scons install

然后编译 tutorial 您还需要将/ usr / local / include / mongo目录指定为include文件搜索路径。

Then to compile code shown in the tutorial you need to also specify the /usr/local/include/mongo directory as a include file search path.

sudo  g++ tutorial.cpp -I/usr/local/include/mongo -lmongoclient 
-lboost_thread -lboost_filesystem -lboost_program_options -o tutorial

然后运行它,你需要编辑/etc/ld.so。 conf文件

Then to run it you will need to edit the /etc/ld.so.conf file

sudo vi /etc/ld.so.conf 

并添加

/usr/local/lib

然后运行

sudo ldconfig

并运行教程

$ ./tutorial 
connected ok

作为编辑ld.so.config文件的替代方法,您可以使用LD_LIBRARY_PATH环境变量。所以你会做

As an alternative to editing the ld.so.config file you can use the LD_LIBRARY_PATH environment variable. So you would do

export LD_LIBRARY_PATH=/usr/local/lib
$ ./tutorial 
connected ok

这篇关于如何在ubuntu安装mongodb驱动程序的c ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆