Inicio > C/C++, Programación > Compilar el driver de MongoDB para C++

Compilar el driver de MongoDB para C++


Hoy he tenido que usar el driver de MongoDB para C++, concretamente junto a QT, y me he encontrado con distintos errores a la hora de compilar del tipo

/usr/include/mongo/db/../bson/bson-inl.h:219: undefined reference to `mongo::msgasserted(int, std::string const&)'
debug/database.o: In function `mongo::BSONObjBuilderValueStream::endField(mongo::StringData const&)':
/usr/include/mongo/db/../bson/bson-inl.h:370: undefined reference to `mongo::verifyFailed(char const*, char const*, unsigned int)'
debug/database.o: In function `mongo::BSONObj::toString(mongo::StringBuilderImpl<mongo::TrivialAllocator>&, bool, bool, int) const':
/usr/include/mongo/db/../bson/bson-inl.h:472: undefined reference to `mongo::msgasserted(int, char const*)'
/usr/include/mongo/db/../bson/bson-inl.h:474: undefined reference to `mongo::msgasserted(int, char const*)'
/usr/include/mongo/db/../bson/bson-inl.h:475: undefined reference to `mongo::msgasserted(int, char const*)'
/usr/include/mongo/db/../bson/bson-inl.h:477: undefined reference to `mongo::msgasserted(int, char const*)'
/usr/include/mongo/db/../bson/bson-inl.h:482: undefined reference to `mongo::msgasserted(int, char const*)'
debug/database.o: In function `mongo::BSONElement::validate() const':
/usr/include/mongo/db/../bson/bson-inl.h:510: undefined reference to `mongo::msgasserted(int, std::string const&)'
/usr/include/mongo/db/../bson/bson-inl.h:515: undefined reference to `mongo::msgasserted(int, char const*)'
/usr/include/mongo/db/../bson/bson-inl.h:517: undefined reference to `mongo::msgasserted(int, char const*)'
/usr/include/mongo/db/../bson/bson-inl.h:518: undefined reference to `mongo::msgasserted(int, char const*)'
/usr/include/mongo/db/../bson/bson-inl.h:521: undefined reference to `mongo::msgasserted(int, char const*)'
/usr/include/mongo/db/../bson/bson-inl.h:523: undefined reference to `mongo::msgasserted(int, char const*)'
debug/database.o:/usr/include/mongo/db/../bson/bson-inl.h:565: more undefined references to `mongo::msgasserted(int, char const*)' follow
debug/database.o: In function `mongo::BSONElement::size(int) const':
/usr/include/mongo/db/../bson/bson-inl.h:596: undefined reference to `mongo::verifyFailed(char const*, char const*, unsigned int)'
/usr/include/mongo/db/../bson/bson-inl.h:607: undefined reference to `mongo::msgasserted(int, char const*)'
debug/database.o: In function `mongo::BSONElement::size() const':
/usr/include/mongo/db/../bson/bson-inl.h:673: undefined reference to `mongo::msgasserted(int, char const*)'
debug/database.o: In function `mongo::BSONElement::toString(mongo::StringBuilderImpl<mongo::TrivialAllocator>&, bool, bool, int) const':
/usr/include/mongo/db/../bson/bson-inl.h:694: undefined reference to `mongo::uasserted(int, std::string const&)'
debug/database.o: In function `mongo::HostAndPort::init(char const*)':
/usr/include/mongo/util/net/hostandport.h:169: undefined reference to `mongo::msgasserted(int, char const*)'
/usr/include/mongo/util/net/hostandport.h:173: undefined reference to `mongo::msgasserted(int, char const*)'
debug/database.o: In function `mongo::DBConnector::recv(mongo::Message&)':
/usr/include/mongo/client/dbclientinterface.h:521: undefined reference to `mongo::verifyFailed(char const*, char const*, unsigned int)'
debug/database.o: In function `mongo::DBClientInterface::~DBClientInterface()':
/usr/include/mongo/client/dbclientinterface.h:552: undefined reference to `vtable for mongo::DBClientInterface'
debug/database.o: In function `mongo::DBClientInterface::DBClientInterface()':
/usr/include/mongo/client/dbclientinterface.h:532: undefined reference to `vtable for mongo::DBClientInterface'
debug/database.o: In function `mongo::DBClientWithCommands::DBClientWithCommands()':
/usr/include/mongo/client/dbclientinterface.h:583: undefined reference to `vtable for mongo::DBClientWithCommands'
debug/database.o: In function `mongo::DBClientWithCommands::~DBClientWithCommands()':
/usr/include/mongo/client/dbclientinterface.h:575: undefined reference to `vtable for mongo::DBClientWithCommands'
debug/database.o: In function `mongo::DBClientBase::DBClientBase()':
/usr/include/mongo/client/dbclientinterface.h:997: undefined reference to `vtable for mongo::DBClientBase'
/usr/include/mongo/client/dbclientinterface.h:997: undefined reference to `vtable for mongo::DBClientBase'
/usr/include/mongo/client/dbclientinterface.h:999: undefined reference to `mongo::DBClientBase::ConnectionIdSequence'
debug/database.o: In function `mongo::UserException::~UserException()':

Tras buscar más rato en Google del que me gustaría he dado con la solución que es añadir todo estas libreráis a la hora de compilar

gcc miprograma.cpp -pthread -lmongoclient -lboost_thread -lboost_filesystem -lboost_program_options -lboost_system -lssl -lcrypto -o miprograma

Si usáis QT como yo, bastará con añadir la linea anterior en el pro de tal forma

LIBS += -pthread -lmongoclient -lboost_thread -lboost_filesystem -lboost_program_options -lboost_system -lssl -lcrypto

Espero que os ayude.

Anuncios
Categorías:C/C++, Programación Etiquetas: , ,
  1. Aún no hay comentarios.
  1. No trackbacks yet.

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: