LINK2019 unresolved externals

48 views
Skip to first unread message

Therefore

unread,
Aug 24, 2012, 5:25:54 PM8/24/12
to mongo...@googlegroups.com
Windows 7 64 SP1
MongoDB 2.2.0-rc1
Boost 1.42
scons 2.2.0
python 2.7.3
MS VS 2010 Ultimate

I'm trying to get the C++ driver installed for use MS VS.

I downloaded 2.2.0-rc1.

Then I:

          scons --64
          scons --dd --64 mongoclient.lib
          scons --dd --64 core
        
all without errors.

I set MS VS Properties: Configuration Properties->vc++ Directories->Include Directories to:
 
           "c:\mongoDB\src"
          
I get this error when building:

            LNK1104: cannot open file 'libboost_thread-vc100-mt-sgd-1_42.lib'
           
Tad Marshal on mongodb-user said earlier this week when I first encountered this: "This variant is for statically linking against the C runtime library ...   Ordinarily, you could download pre-built libraries from http://www.boostpro.com/download/ , but for Boost version 1.42 they don't have a Visual Studio 2010 set, so for 1.42 and VC 10.0 you need to build your own."

So, I downloaded boost_1_42_0.7z from boost.org, unpacked it into C:\boost_1_42_0\ and renamed to c:\boost\. Then with MS VS x64 Command Prompt:

    cd c:\boost
    bjam msvc stage --build-type=complete address-model=64
   
I added to MS VS Properties: Configuration Properties->vc++ Directories->Include Directories

     c:\boost
    
I added to MS VS Properties: Configuration Properties->Linker->General->Additional Library Directories

      c:\boost\stage\lib
     
(note: I tried copying c:\boost\stage\lib to c:\boost\lib as you earlier suggested, and got the same following result)

I set Properties: Configuration Properties-> C/C++->Code Generation select:

                     /MTd
                    
I added to Properties: Configuration Properties --> C/C++ -> Preprocessor->Precprocessor Definitions:

                    _CRT_SECURE_NO_WARNINGS                   
                   
The result is 55 LINK2019 unresolved externals. E.g.,

1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Start mongo.obj : error LNK2001: unresolved external symbol "protected: static struct mongo::AtomicUInt mongo::DBClientConnection::_numConnections" (?_numConnections@DBClientConnection@mongo@@1UAtomicUInt@2@A)
1>Start mongo.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall mongo::DBClientBase::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 &,int)" (?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@H@Z)
1>Start mongo.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall mongo::DBClientBase::insert(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class mongo::BSONObj,int)" (?insert@DBClientBase@mongo@@UAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VBSONObj@2@H@Z)

I believe this is where I was earlier in the week.

Here is the source:

#include <iostream>
#include "mongo/client/dbclient.h"

using namespace mongo;

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

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

Thoughts?

Mark



Therefore

unread,
Aug 24, 2012, 5:33:09 PM8/24/12
to mongo...@googlegroups.com
My cut and paste of the source neglected the fist #include:

        #include "StdAfx.h"

Which obviously I need.

Therefore

unread,
Aug 25, 2012, 10:11:38 PM8/25/12
to mongo...@googlegroups.com
I finally solved this, with Tad's help, by adding explicitly adding "C:\mongodb\mongoclient.lib" to Properties: Configuration Properties->vc++ Directories->Include Directories.

Which kind of surprises me but I'm thankful I compiled!

Onward! Thanks for all your help!
Reply all
Reply to author
Forward
0 new messages