Make sure you're targeting x64 in properties->Configuration Manager
On Sunday, December 9, 2012 6:16:47 PM UTC-8, Peng Liu wrote:I try to write a test application to try how to use mongoclient.lib on 64bit Windows 7 SP1. I use Visual Studio 2010 Professional and Boost 1.4.2. I built the Boost library by myself with the command:
bjam msvc stage --build-type=complete address-model=64
I built the mongodb components with the command:
scons --64
scons --dd --64 mongoclient.lib
scons --dd --64 core
Then I copy the boost src files, library and mongo src files and mongoclient.lib to my specific third party source and lib directories, such as ThirdParty\boost including boost and lib subdirectory, ThirdParty\mongodb including include and lib subdirectory.
In my test application solution, I modify the project properties as follow:
1. VC Diretories->"Include Directories" and "Library Directories": add my specific third party source directory.
2. C/C++->Proprocessor Definition: add _CRT_SECURE_NO_WARNINGS
3. C/C++->Code Generation->Runtime library: MTd
4. Linker->Input: add ws2_32.lib, dbghelp.lib, mongoclient.lib and the 5 boost libraries.
The code is as follow:
#include "stdafx.h"
#include <iostream>
#include "mongo/client/dbclient.h"
using namespace std;
using namespace mongo;
using namespace bson;
int _tmain(int argc, _TCHAR* argv[])
{
try
{
cout << "connect to localhost mongodb server" << endl;
DBClientConnection c;
c.connect("localhost");
string errstr = c.getLastError();
}
catch(DBException& e) {
cout << "caught DBException " << e.toString() << endl;
return 1;
}
return 0;
}
Then I get the building errors below.
I also try the boost prebuilt library downloaded from http://www.mongodb.org/pages/viewpageattachments.action?pageId=12157032. But fail.
I can build the example project which is in mongodb source and run dbclient without library.
Can any experts help that?
Thanks.
1>------ Build started: Project: MongoDBAccess, Configuration: Debug x64 ------
1>mongoclient.lib(log.obj) : error LNK2019: unresolved external symbol "class boost::filesystem2::file_status __cdecl boost::filesystem2::detail::status_api(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::system::error_code &)" (?status_api@detail@filesystem2@boost@@YA?AVfile_status@23@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAVerror_code@system@3@@Z) referenced in function "bool __cdecl boost::filesystem2::exists<class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> >(class boost::filesystem2::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem2::path_traits> const &)" (??$exists@V?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem2@boost@@@filesystem2@boost@@@filesystem2@boost@@YA_NAEBV?$basic_path@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@Upath_traits@filesystem2@boost@@@01@@Z)
1>mongoclient.lib(util.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ)
1>mongoclient.lib(dbmessage.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ)
1>mongoclient.lib(log.obj) : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "public: __cdecl boost::system::error_code::error_code(void)" (??0error_code@system@boost@@QEAA@XZ)
1>mongoclient.lib(syncclusterconnection.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ)
1>mongoclient.lib(dbclient_rs.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ)
1>mongoclient.lib(dbclientcursor.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ)
1>mongoclient.lib(util.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ)
1>mongoclient.lib(dbmessage.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ)
1>mongoclient.lib(log.obj) : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (??__Eposix_category@system@boost@@YAXXZ)
1>mongoclient.lib(syncclusterconnection.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ)
1>mongoclient.lib(dbclient_rs.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ)
1>mongoclient.lib(dbclientcursor.obj) : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ)
1>D:\Private\Test\MongoDBDemo\MongoDBAccess\x64\Debug\MongoDBAccess.exe : fatal error LNK1120: 3 unresolved externals
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-dev/-/aYvV1tyDwKUJ.
To post to this group, send email to mongo...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-dev?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-dev/-/TTIJPjorUrAJ.
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-dev/-/H4TYw1efmioJ.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-dev/-/29PiTaPIhT4J.