I am using poco library to connect to mongodb. My code is getting compiled but while running out file it is giving me the below error
./test_mongo: error while loading shared libraries: libPocoMongoDB.so.71: cannot open shared object file: No such file or directory
libPocoMongoDB.so.71 is already existing at /usr/local/lib
Here is my c++ code
#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Connection.h"
#include "Poco/MongoDB/Database.h"
#include "Poco/MongoDB/Cursor.h"
#include "Poco/MongoDB/Array.h"
int main(int argc, char** argv)
{
try
{
Poco::MongoDB::Connection connection("localhost", 27017);
}
catch (Poco::Exception& exc)
{
std::cerr << exc.displayText() << std::endl;
}
return 0;
}
I compiled it using below command
g++ -o test_mongo test_mongo.cpp -I/usr/local/include -L/usr/local/lib/ -lPocoMongoDB -lPocoNet -lPocoFoundation
There are two ways to resolve it