Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-2374

LNK2019: unresolved external symbol "__declspec(dllimport) using MongoDB in static mode

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Unknown Unknown
    • None
    • None
    • None
    • None

    Description

      Hey

       

      Ive build mongo C in static mode. 2x, 1x for debug, and 1x for debug-release.

      Between each build, I copied the generated files to a new folder as the debug files do not come with "d" suffix which then overwrites other files.

       

      With these files, I then configures mongo CXX to use static mongo C files and asked it to produce both Static & Shared libraries.

       

      That has been compiled. For this, I made 2 vs projects. 1 for debug and 1 for debug-release so to not confuse configs...

      I linked each project to their proper mongo C .lib files.

      So I end up with

      Mongo C & Mongo CXX in debug

      Mongo C & Mongo CXX in debug release.

      I've then included the resulting lib files in my cmake project using if statement to determine if I'm in debug or not >

      if (CMAKE_BUILD_TYPE MATCHES Debug)
          set(3rd_libs_MONGO
                  ${MONGODB_ROOT}lib/bsoncxxd.lib
                  ${MONGODB_ROOT}lib/bson-static-1.0d.lib
                  ${MONGODB_ROOT}lib/mongoc-static-1.0d.lib
                  ${MONGODB_ROOT}lib/bsoncxx-staticd.lib
                  ${MONGODB_ROOT}lib/mongocxx-staticd.lib
                  )
      else ()
          set(3rd_libs_MONGO
                  ${MONGODB_ROOT}lib/bsoncxx.lib
                  ${MONGODB_ROOT}lib/bson-static-1.0.lib
                  ${MONGODB_ROOT}lib/mongoc-static-1.0.lib
                  ${MONGODB_ROOT}lib/bsoncxx-static.lib
                  ${MONGODB_ROOT}lib/mongocxx-static.lib
                  )
      endif ()
      target_link_libraries(${PROJECT_NAME} ${3rd_libs_MONGO})

      After that when I try to run the app I get > 

      main.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl mongocxx::v_noabi::options::client_session::client_session(void)" (__imp_??0client_session@options@v_noabi@mongocxx@@QEAA@XZ) referenced in function "void __cdecl arrayTests(void)" (?arrayTests@@YAXXZ)
      

      and 300 more errors like this.

       

      This project was working with previous dynamic libraries, .dll, from last year. But as I was updating mongo I figures I might as well go with static & recompile it all.

      How can I "fix" this issue? 

      Regards

      Dariusz

       

      Win10x64

      vs 17+ 

      Attachments

        Activity

          People

            ezra.chung@mongodb.com Ezra Chung
            dariusz1989@gmail.com Dariusz D
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: