2014-02-28 49 views
0

我得到的錯誤錯誤LNK2005:無效__cdecl蒙戈:: uasserted(...)已經定義

mongoclient.lib(assert_util.obj) : error LNK2005: void __cdecl mongo::uasserted(...) already defined in someOwnFile.obj

在鏈接,與mongo::msgassertedmongo::msgasserted一起。

someOwnFile.cpp,我有

#include <string> 

#ifdef WIN32 
// Needed for mongo BSON. 
#pragma warning(push) 
#pragma warning(disable: 4800) 
#pragma warning(disable: 4244) 
#pragma warning(disable: 4267) 
#define _CRT_SECURE_NO_WARNINGS 1 
#endif 

#include <mongo/bson/bson.h> 

#ifdef WIN32 
#pragma warning(pop) 
#endif 

// ... 

爲什麼會出錯?我該如何解決它?

回答

0

看來,它包括剛纔這個文件時有問題。

現在我這樣做:

#ifdef WIN32 
// Mongo uses boost.filesystem. Include it here to force to link it in (via its pragma lib). 
#include <boost/filesystem.hpp> 

// Needed for mongo BSON. 
#pragma warning(push) 
#pragma warning(disable: 4800) 
#pragma warning(disable: 4244) 
#pragma warning(disable: 4267) 
#define _CRT_SECURE_NO_WARNINGS 1 
#endif 

#include <mongo/client/dbclient.h> 
#include <mongo/client/dbclient_rs.h> 
#include <mongo/client/gridfs.h> 

#ifdef WIN32 
#pragma warning(pop) 
#endif 

而這個工作。