1024programmer Mongodb How Linux compiles the c++ client of MongoDB database

How Linux compiles the c++ client of MongoDB database

Preparation before installation:
1/ Install the boost library
2/ Install the scons program

Method 1:
$ git clone git://github.com/mongodb/mongo.git
$ cd mongo
$ cat docs/building.md
$ scons .

After a period of compilation, the server and client of mongodb, as well as the c++ client library can be generated.

Method 2: Use scons to compile (the scons program must be installed first)
Download the mongo source code from the official website (http://www.mongodb.org/downloads), the version I downloaded is
mongodb-src-r2.0.7.tar.gz
After decompression, generate mongodb-src-r2.0.7 directory, cd to this directory
Then execute the command:
scons –prefix=/urs/local/mongo

At that time, three directories bin, include, lib will be generated in /urs/local/mongo

in:

The bin contains the server and client of mongo, and some other tools

include is the header file of mongo

lib is the client library, the cpp client library generated here

Finish!

In the source code directory, there are some simple test samples under client/example, which can be compiled:

cd to client/example

compile first.cpp

g++ first.cpp -o first
-I/usr/local/mongo/include/mongo -L/usr/local/mongo/lib
-llibmongoclient.a -lboost_thread -lboost_filesystem
-lboost_program_options -lboost_system

Compile clientTest.cpp

g++ clientTest.cpp -o clientTest
-I/usr/local/mongo/include/mongo -L/usr/local/mongo/lib
-llibmongoclient.a -lboost_thread -lboost_filesystem
-lboost_program_options -lboost_system

Note:

Be careful about the linking order of the libraries in the compilation command, it will affect whether the compilation is successful! ! !

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/how-linux-compiles-the-c-client-of-mongodb-database/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索