提出问题提出问题
 

常规讨论MS2008 linking problem vc++

  • 2009年11月4日 13:39Chetan Sheladiya 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    HI I am using boost library(1.40) genrated files, that files generated while boost installation variant option are (multithread, static runtime)& VS2008. i try to call a mongodb server by simple client program
    ---------------------------------simple connect code ------------------
    #include <iostream>
    #include "C:\\data\\db\\include\\mongo\\client\\dbclient.h"

    #pragma comment( lib, "mongoclient.lib" )
    using namespace mongo;

    void run() {
    DBClientConnection c;
    // c.connect("local");
    }

    int main() {
    try {
    run();
    cout << "connected ok" << endl;
    } catch( DBException &e ) {
    cout << "caught " << e.what() << endl;
    }
    return 0;
    }

    -----------------------------------code end -------------------
    i also provide library and include path in visual studio ->tools->option->vc directory->library & include

    but it display me this error list. if i remove lib path from tools->option then it demand me the list of lib files are :
    1.libboost_date_time-vc90-mt-1_40.lib
    2.libboost_filesystem-vc90-mt-1_40.lib
    3.libboost_system-vc90-mt-1_40.lib
    4.libboost_thread-vc90-mt-1_40.lib
    5.libboost_program_options-vc90-mt-1_40.lib

    but if path is right then it display this linking error :


    **************************************************************************
    1>------ Build started: Project: ttu64, Configuration: Release Win32 ------
    1>Linking...
    1>ttu32.obj : error LNK2001: unresolved external symbol "private: static struct mongo::BSONObj::EmptyObject mongo::BSONObj::emptyObject" (?emptyObject@BSONObj@mongo@@0UEmptyObject@12@A)
    1>ttu32.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall mongo: BClientConnection::checkResponse(char const *,int)" (?checkResponse@DBClientConnection@mongo@@MAEXPBDH@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall mongo: BClientConnection::sayPiggyBack(class mongo::Message &)" (?sayPiggyBack@DBClientConnection@mongo@@MAEXAAVMessage@2@@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall mongo: BClientConnection::say(class mongo::Message &)" (?say@DBClientConnection@mongo@@MAEXAAVMessage@2@@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "protected: virtual bool __thiscall mongo: BClientConnection::call(class mongo::Message &,class mongo::Message &,bool)" (?call@DBClientConnection@mongo@@MAE_NAAVMessage@2@0_N@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall mongo: BClientConnection::auth(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,bool)" (?auth@DBClientConnection@mongo@@UAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00AAV34@_N@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall mongo: BClientConnection::connect(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?connect@DBClientConnection@mongo@@UAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAV34@@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "private: void __thiscall mongo: BClientConnection::_checkConnection(void)" (?_checkConnection@DBClientConnection@mongo@@AAEXXZ)
    1>ttu32.obj : error LNK2001: unresolved external symbol "class mongo::Logstream mongo::logstream" (?logstream@mongo@@3VLogstream@1@A)
    1>ttu32.obj : error LNK2001: unresolved external symbol "private: static class boost::mutex & mongo::Logstream::mutex" (?mutex@Logstream@mongo@@0AAV0boost@@A)
    1>ttu32.obj : error LNK2001: unresolved external symbol "int mongo::logLevel" (?logLevel@mongo@@3HA)
    1>ttu32.obj : error LNK2001: unresolved external symbol "char const * const mongo::curNs" (?curNs@mongo@@3PBDB)
    1>ttu32.obj : error LNK2001: unresolved external symbol "class mongo::Nullstream mongo::nullstream" (?nullstream@mongo@@3VNullstream@1@A)
    1>ttu32.obj : error LNK2001: unresolved external symbol "void __cdecl mongo::asserted(char const *,char const *,unsigned int)" (?asserted@mongo@@YAXPBD0I@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "void __cdecl mongo::dbexit(enum mongo::ExitCode,char const *)" (?dbexit@mongo@@YAXW4ExitCode@1@PBD@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall mongo: BClientWithCommands::isMaster(bool &,class mongo::BSONObj *)" (?isMaster@DBClientWithCommands@mongo@@UAE_NAA_NPAVBSONObj@2@@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall mongo: BClientWithCommands::auth(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,bool)" (?auth@DBClientWithCommands@mongo@@UAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00AAV34@_N@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: bool __thiscall mongo: BClientWithCommands::runCommand(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class mongo::BSONObj const &,class mongo::BSONObj &)" (?runCommand@DBClientWithCommands@mongo@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABVBSONObj@2@AAV52@@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: bool __thiscall mongo: BClientWithCommands::simpleCommand(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class mongo::BSONObj *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?simpleCommand@DBClientWithCommands@mongo@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAVBSONObj@2@0@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "void __cdecl mongo::msgasserted(char const *)" (?msgasserted@mongo@@YAXPBD@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall mongo: BClientBase::resetIndexCache(void)" (?resetIndexCache@DBClientBase@mongo@@UAEXXZ)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall mongo: BClientBase::ensureIndex(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class mongo::BSONObj,bool,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?ensureIndex@DBClientBase@mongo@@UAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VBSONObj@2@_N0@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall mongo: BClientBase::update(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class mongo::Query,class mongo::BSONObj,bool)" (?update@DBClientBase@mongo@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VQuery@2@VBSONObj@2@_N@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall mongo: BClientBase::remove(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class mongo::Query,bool)" (?remove@DBClientBase@mongo@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VQuery@2@_N@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall mongo: BClientBase::insert(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class mongo::BSONObj)" (?insert@DBClientBase@mongo@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VBSONObj@2@@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall mongo: BClientBase::insert(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<class mongo::BSONObj,class std::allocator<class mongo::BSONObj> > const &)" (?insert@DBClientBase@mongo@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$vector@VBSONObj@mongo@@V?$allocator@VBSONObj@mongo@@@std@@@4@@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual class mongo::BSONObj __thiscall mongo: BClientBase::findOne(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class mongo::Query,class mongo::BSONObj const *,int)" (?findOne@DBClientBase@mongo@@UAE?AVBSONObj@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VQuery@2@PBV32@H@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual class std::auto_ptr<class mongo: BClientCursor> __thiscall mongo: BClientBase::getMore(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,__int64,int,int)" (?getMore@DBClientBase@mongo@@UAE?AV?$auto_ptr@VDBClientCursor@mongo@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@_JHH@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "public: virtual class std::auto_ptr<class mongo: BClientCursor> __thiscall mongo: BClientBase::query(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class mongo::Query,int,int,class mongo::BSONObj const *,int)" (?query@DBClientBase@mongo@@UAE?AV?$auto_ptr@VDBClientCursor@mongo@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@VQuery@2@HHPBVBSONObj@2@H@Z)
    1>ttu32.obj : error LNK2001: unresolved external symbol "void __cdecl mongo::uasserted(char const *)" (?uasserted@mongo@@YAXPBD@Z)
    1>C:\data\db\ttu64\Release\ttu64.exe : fatal error LNK1120: 30 unresolved
    externals
    1>Build log was saved at "file://c:\data\db\ttu64\ttu64\Release\BuildLog.htm"

    **************************************************************************

    thanks,
    -CC

全部回复

  • 2009年11月4日 15:02«_Superman_»MVP用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Change the #pragma to
    #pragma comment( lib, "mongoclient" )

    «_Superman_»
    Microsoft MVP (Visual C++)
  • 2009年11月6日 3:22Nancy ShaoMSFT, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Hi Chetan,

    Are you sure that you have include correct Header file(.h) to project? dbclient.h but not mongoclient.h? And use the correct namespace?

    Best Regards,
    Nancy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • 2009年11月11日 3:21Nancy ShaoMSFT, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Hi Chetan,

    We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

    Thank you!

    Best Regards,
    Nancy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.