使用Rcpp和Mongodb构建软件包时如何解决未定义的参考错误

时间:2019-05-06 17:41:15

标签: r mongodb gcc rcpp

我正在构建一个使用Rcpp的R包,需要与mongodb c ++驱动程序一起使用。我正在使用Windows,并通过柯南软件包管理器安装了mongo c驱动程序(版本1.11.0)和mongo cxx驱动程序(版本3.3.0)。使用柯南指导,我构建驱动程序,并将生成的conanbuildinfo.gcc文件的内容用于我的Makevars文件中的PKG_CXXFLAGS标志。

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

当我在Rstuido中的Cpp文件中编码时,它会识别mongo标头,并为我键入时提供自动完成的建议。当我尝试构建软件包时,出现错误:

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 status
no DLL was created
ERROR: compilation failed for package 'DenovoTagScoring'

这是由以下代码引起的:

mongocxx::instance inst{};

在网上浏览并阅读了SO帖子后,我认为编译器未正确链接到我需要使用的标头。我不知道如何解决此问题,将不胜感激。用于构建我的程序包的编译器是gcc 4.9.3。

0 个答案:

没有答案