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

How to fix undefined reference error when building package with Rcpp and Mongodb

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Gone away
    • Icon: Major - P3 Major - P3
    • None
    • 3.3.0
    • None
    • None
    • Windows Server2012 R2, Conan Package Manager, gcc

    Description

      I'm building an R package that uses Rcpp and needs to work with the mongodb c++ driver. I'm using Windows and installed the mongo c driver(version 1.11.0) and mongo cxx driver (version 3.3.0) through the conan package manager. Using the directions for conan, I build the drivers and use the contents of the generated conanbuildinfo.gcc file for my PKG_CXXFLAGS flag in my Makevars file.

       

      {{PKG_CXXFLAGS = -DBSON_STATIC=1 -DMONGOC_STATIC=1 -DBOOST_ALL_NO_LIB=1 -IC:/Users/colo636/.conan/data/mongo-cxx-driver/3.3.0/bincrafters/stable/package/787d2040e5c5d961041d0db2cb2d77bf26dc9a9a/include -IC:/.conan/ed2f7f1/1/optional/include -IC:/.conan/3e444eb/1/smart_ptr/include -IC:/.conan/63e56dc/1/system/include -IC:/Users/colo636/.conan/data/mongo-c-driver/1.11.0/bincrafters/stable/package/656b7d2856e464c5e4f11518a9b153f1852b5edf/include -IC:/.conan/2318cdc/1/detail/include -IC:/.conan/a2a6117/1/move/include -IC:/.conan/53e86f8/1/winapi/include -IC:/Users/colo636/.conan/data/zlib/1.2.11/conan/stable/package/425ec5c941593abc5ec9394a8eee44bcaa6409d0/include -IC:/.conan/48284bb/1/mpl/include -IC:/.conan/ca312fa/1/predef/include -IC:/.conan/631754d/1/utility/include -IC:/.conan/875bb67/1/preprocessor/include -IC:/.conan/c78d9bb/1/type_traits/include -IC:/.conan/5d668c3/1/throw_exception/include -IC:/.conan/4cf2c0b/1/core/include -IC:/.conan/e8e5732/1/static_assert/include -IC:/.conan/305ebe9/1/assert/include -IC:/.conan/e266456/1/config/include -m64 -O3 -s -DNDEBUG -Wl,-rpath="C:/Users/colo636/.conan/data/mongo-cxx-driver/3.3.0/bincrafters/stable/package/787d2040e5c5d961041d0db2cb2d77bf26dc9a9a/lib" -Wl,-rpath="C:/.conan/ed2f7f1/1/optional/lib" -Wl,-rpath="C:/.conan/3e444eb/1/smart_ptr/lib" -Wl,-rpath="C:/.conan/63e56dc/1/system/lib" -Wl,-rpath="C:/Users/colo636/.conan/data/mongo-c-driver/1.11.0/bincrafters/stable/package/656b7d2856e464c5e4f11518a9b153f1852b5edf/lib" -Wl,-rpath="C:/.conan/2318cdc/1/detail/lib" -Wl,-rpath="C:/.conan/a2a6117/1/move/lib" -Wl,-rpath="C:/.conan/53e86f8/1/winapi/lib" -Wl,-rpath="C:/Users/colo636/.conan/data/zlib/1.2.11/conan/stable/package/425ec5c941593abc5ec9394a8eee44bcaa6409d0/lib" -Wl,-rpath="C:/.conan/48284bb/1/mpl/lib" -Wl,-rpath="C:/.conan/ca312fa/1/predef/lib" -Wl,-rpath="C:/.conan/631754d/1/utility/lib" -Wl,-rpath="C:/.conan/875bb67/1/preprocessor/lib" -Wl,-rpath="C:/.conan/c78d9bb/1/type_traits/lib" -Wl,-rpath="C:/.conan/5d668c3/1/throw_exception/lib" -Wl,-rpath="C:/.conan/4cf2c0b/1/core/lib" -Wl,-rpath="C:/.conan/e8e5732/1/static_assert/lib" -Wl,-rpath="C:/.conan/305ebe9/1/assert/lib" -Wl,-rpath="C:/.conan/e266456/1/config/lib" -LC:/Users/colo636/.conan/data/mongo-cxx-driver/3.3.0/bincrafters/stable/package/787d2040e5c5d961041d0db2cb2d77bf26dc9a9a/lib -LC:/.conan/ed2f7f1/1/optional/lib -LC:/.conan/3e444eb/1/smart_ptr/lib -LC:/.conan/63e56dc/1/system/lib -LC:/Users/colo636/.conan/data/mongo-c-driver/1.11.0/bincrafters/stable/package/656b7d2856e464c5e4f11518a9b153f1852b5edf/lib -LC:/.conan/2318cdc/1/detail/lib -LC:/.conan/a2a6117/1/move/lib -LC:/.conan/53e86f8/1/winapi/lib -LC:/Users/colo636/.conan/data/zlib/1.2.11/conan/stable/package/425ec5c941593abc5ec9394a8eee44bcaa6409d0/lib -LC:/.conan/48284bb/1/mpl/lib -LC:/.conan/ca312fa/1/predef/lib -LC:/.conan/631754d/1/utility/lib -LC:/.conan/875bb67/1/preprocessor/lib -LC:/.conan/c78d9bb/1/type_traits/lib -LC:/.conan/5d668c3/1/throw_exception/lib -LC:/.conan/4cf2c0b/1/core/lib -LC:/.conan/e8e5732/1/static_assert/lib -LC:/.conan/305ebe9/1/assert/lib -LC:/.conan/e266456/1/config/lib -lmongocxx -lbsoncxx -lboost_system -lmongoc-static-1.0 -lbson-static-1.0 -lws2_32.lib -lsecur32.lib -lcrypt32.lib -lBCrypt.lib -lDnsapi.lib -lzlib -D_GLIBCXX_USE_CXX11_ABI=1
      }}

      When I'm coding in a Cpp file in Rstuido, it recognizes the mongo headers and offers suggestions for auto completion when I'm typing. When I try to build the package, I get the error:

       
       
      {{c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o DenovoTagScoring.dll tmp.def RcppExports.o peptide_scoring_w_mass_working_copy.o -LC:/PROGRA~1/R/R-35~1.2/bin/x64 -lR
      peptide_scoring_w_mass_working_copy.o:peptide_scoring_w_mass_working_copy.cpp.text+0x210f): undefined reference to `mongocxx::v_noabi::instance::instance()'
      peptide_scoring_w_mass_working_copy.o:peptide_scoring_w_mass_working_copy.cpp.text+0x2de7): undefined reference to `mongocxx::v_noabi::instance::~instance()'
      peptide_scoring_w_mass_working_copy.o:peptide_scoring_w_mass_working_copy.cpp.text+0x4623): undefined reference to `mongocxx::v_noabi::instance::~instance()'collect2.exe: error: ld returned 1 exit statusno DLL was created
      ERROR: compilation failed for package 'DenovoTagScoring'}}

       

      This is caused by the code: 
       
      mongocxx::instance inst{};

       
      After looking online and reading Stack Overflow posts, I think that the compiler isn't properly linking to the headers I need to use. I don't know how to fix this issue and would appreciate any help solving this issue. The compiler used to build my package is gcc 4.9.3.
       

      Attachments

        Activity

          People

            Unassigned Unassigned
            christian.colon Christian Colon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: