1

I am using c++ legacy driver, I built a class with many mongoDB operations in different functions.

I don't want to define the mongo::DBClientReplicaSet in every function but if I define it in the global level, I had another problem because I need to call mongo::client::initialize before I construct any driver objects, or BSON for that matter. That means if I call mongo::client::initialize in the class construct function, I cannot define mongo::DBClientReplicaSet before that. So it cannot be declared in the global level. I tried "extern mongo::DBClientReplicaSet xxxx" and then defined it in class construct function but got link error :

error LNK2001: unresolved external symbol "class mongo::DBClientReplicaSet xxxx"

because we cannot use mongo::DBClientReplicaSet without parameters.

Does anybody know a solution for this?

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
Harold
  • 33
  • 5
  • Why are you using the legacy driver, rather than the newer C++11 driver, mongocxx? – acm Feb 21 '17 at 02:17

0 Answers0