简体   繁体   English

在Ubuntu中包含MongoDB C ++驱动程序时出错

[英]Error in including MongoDB C++ driver in Ubuntu

I have been trying to connect C++ with MongoDB but it gave errors on many levels and now I'm stuck at compiling a simple code. 我一直在尝试将C ++与MongoDB连接,但是它在许多级别上都产生了错误,现在我只能编译一个简单的代码。 I have followed this tutorial . 我遵循了本教程 And I tried to compile the code given in the tutorial using the command below. 我尝试使用下面的命令编译本教程中给出的代码。

g++ tutorial.cpp -Iinstall/include -Linstall/lib -pthread -lmongoclient -lboost_thread -lboost_filesystem -lboost_program_options -lboost_system -o tutorial

But it prints a huge log on the console and exits with a error. 但它会在控制台上打印大量日志,并退出并显示错误。 The final part output is below. 最终零件输出如下。

 nce to `boost::re_detail::put_mem_block(void*)'
install/lib/libmongoclient.a(dbclient.o): In function `perl_matcher':
/usr/include/boost/regex/v4/perl_matcher.hpp:374: undefined reference to `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init(boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)'
install/lib/libmongoclient.a(dbclient.o): In function `boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::match_match()':
/usr/include/boost/regex/v4/perl_matcher_non_recursive.hpp:973: undefined reference to `boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > >::maybe_assign(boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > > > const&)'
collect2: error: ld returned 1 exit status

Can someone explain how to correct this issue? 有人可以解释如何解决此问题吗?

I have corrected this error by adding "lboost_regex" to the build path. 我已通过在构建路径中添加“ lboost_regex”来更正此错误。 I have corrected all the errors in official tutorial here in this blog post. 我已经在官方教程纠正所有的错误在这里的这个博客帖子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM