This version still does not solve the problem that dynamic libraries cannot be compiled. What are the nerves of MongoDB?
It turns out that the two bypass methods will not work either.
Only static databases are used.
Download and compile the latest code.
Scons -- prefix =/usr install
An error is reported when the old C ++ code is compiled, because the ScopedDbConnection constructor is private and must be created through static methods.
Therefore, the calling code must be adjusted accordingly.
The configuration of my CMake project is as follows:
Target_link_libraries (service $ {Boost_LIBRARIES} booster loki cryptopp encryption client)
There should be no problem.
Share my C ++ encapsulation class:
# Ifndef business_util_pai_session_h _
# Define business_util_pai_session_h _
# Include <string>
# Include <memory>
# Include <mongo/client/connpool. h>
Using std: string;
Class reset session {
Public:
/**
* Obtain the connection from the connection pool. If no connection exists, create
*/
Reset SESSION (string const & host, double socketTimeout = 0 );
/**
* Return the connection to the pool
*/
~ Reset SESSION ();
/**
* Returns the obtained connection.
*/
Mongo: DBClientBase & GetDBClientBase ();
Private:
Std: auto_ptr <mongo: ScopedDbConnection> con _;
};
# Endif
MongoDB details: click here
MongoDB: click here
Recommended reading:
CentOS compilation and installation of MongoDB
CentOS compilation and installation of php extensions for MongoDB and mongoDB
CentOS 6 install MongoDB and server configuration using yum
Install MongoDB2.4.3 in Ubuntu 13.04
How to create a new database and set in MongoDB
MongoDB beginners must read (both concepts and practices)