I am trying to run mongoDB client under C++ as a part of my shared library on 64-bit Ubuntu.
I have downloaded nightly version of mongodb c++ driver, as explained step-by-step at http://programmingknowledgeblog.blogspot.de/2013/02/how-to-run-and-install-mongo-c-drivers.html. I have (only?) changed the SConfigure script by adding -fPIC flag to CCFLAGS, because (as far as I know) there is no other way to link static library with shared library under 64-bit system. Then I have installed mongodb driver using scons.
I have run MongoDB server as well, using mongodb-10gen version.
I have defined linking to shared libraries in CMakeLists.txt file. It looks like this:target_link_libraries(MyGridFS mongoclient boost_thread-mt boost_filesystem-mt boost_program_options-mt)
target_link_libraries(MongoDbDataSourceAdapter MyGridFS)
target_link_libraries(Accessop SMOperatorInitParam SMByteArrayHeader MongoDbDataSourceAdapter RealTimeDataSourceAdapter EndOfStreamHandler)
Now, it is enough that Accessop.so is called (not even a line of code is executed - furthermore, the code I use right now in Accessop class does not use mongoDB functionality at all) and such an exception appears:Attempt to add global initializer failed, status: DuplicateKey throwSockExcep
Caught signal (6)
Stacktrace:
at gsignal (/lib/x86_64-linux-gnu/libc.so.6)
at abort (/lib/x86_64-linux-gnu/libc.so.6)
at mongo::GlobalInitializerRegisterer::GlobalInitializerRegisterer(std::string const&, boost::function<mongo::Status (mongo::InitializerContext*)> const&, std::vector<std::string, std::allocator<std::string> > const&, std::vector<std::string, std::allocator<std::string> > const&) (/local/mt1/workspace/example-third/build/libAccessop.so)
at (/local/mt1/workspace/example-third/build/libAccessop.so)
at (/lib64/ld-linux-x86-64.so.2)
at (/lib64/ld-linux-x86-64.so.2)
at (/lib64/ld-linux-x86-64.so.2)
at (/lib64/ld-linux-x86-64.so.2)
at (/lib64/ld-linux-x86-64.so.2)
at (/lib/x86_64-linux-gnu/libdl.so.2)
at (/lib64/ld-linux-x86-64.so.2)
at (/lib/x86_64-linux-gnu/libdl.so.2)
at dlopen (/lib/x86_64-linux-gnu/libdl.so.2)...
The code that is a source of this exception is available at:
https://github.com/mongodb/mongo-perf/blob/master/mongo-cxx-driver/src/mongo/base/global_initializer_registerer.cpp
Does anyone have an idea what could be the reason of this exception appearing? Status value says nothing much constructive...