I am trying to create a dynamic(.so) wrapper library along mongoDB c++ driver. There is no problem with the compilation but when I test it in a C++ sample program i get the error
Code:undefined symbol: _ZN5mongo18DBClientConnection15_numConne
which i assume has something to do with name mangling issues.
I compiled the library as
Here's the program I am using for testing:Code:g++ -fPIC -shared mongoquery.cpp -I/pathto/mongodriver -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_program_options -o libmongoquery.so
the header mongoquery.hpp containsCode:#include <iostream> #include <dlfcn.h> #include "mongoquery.hpp" using namespace std; int main() { void *lib_handle; int (*fn)(int *,string); lib_handle=dlopen("./libmongoquery.so",RTLD_NOW); if(!lib_handle) { cerr<<"Error"<<dlerror(); return 1; } fn=(int (*)(int *,string))dlsym(lib_handle,"count_query"); string q="{}"; int n; (*fn)(&n,q); cout<<n; dlclose(lib_handle); return 0; }
Code:#include <iostream> #include <client/dbclient.h> #define HOST "localhost" #define COLLECTION "test.rules" using namespace mongo; using namespace std; class mongoquery { private: string q; mongo::DBClientConnection c; public: mongoquery(string); int result_count(); }; int count_query(int *,string);



4Likes
LinkBack URL
About LinkBacks



