【问题标题】:undefined reference to boost::program_options in vowpalwabbit compilation, ubuntu 16.04vowpalwabbit 编译中对 boost::program_options 的未定义引用,ubuntu 16.04
【发布时间】:2017-09-05 08:32:35
【问题描述】:

我正在尝试在 ubuntu 16.04 中安装 vowpal_wabbit
错误:

./libvw.a(search.o): In function `Search::setup(vw&)':
search.cc:(.text+0xa5f8): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
search.cc:(.text+0xaafe): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::string const&) const'
search.cc:(.text+0xac0e): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::string const&) const'
search.cc:(.text+0xad20): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::string const&) const'
search.cc:(.text+0xadda): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::string const&) const'
search.cc:(.text+0xae94): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::string const&) const'
./libvw.a(search.o):search.cc:(.text+0xafaa): more undefined references to `boost::program_options::abstract_variables_map::operator[](std::string const&) const' follow
./libvw.a(search_meta.o): In function `SelectiveBranchingMT::initialize(Search::search&, unsigned long&, boost::program_options::variables_map&)':
search_meta.cc:(.text+0x7645): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
./libvw.a(search_sequencetask.o): In function `SequenceSpanTask::initialize(Search::search&, unsigned long&, boost::program_options::variables_map&)':
search_sequencetask.cc:(.text+0x14ab): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
./libvw.a(search_sequencetask.o): In function `ArgmaxTask::initialize(Search::search&, unsigned long&, boost::program_options::variables_map&)':
search_sequencetask.cc:(.text+0x2a02): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
./libvw.a(search_dep_parser.o): In function `DepParserTask::initialize(Search::search&, unsigned long&, boost::program_options::variables_map&)':
search_dep_parser.cc:(.text+0x4328): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
./libvw.a(search_dep_parser.o): In function `void Search::check_option<unsigned int>(unsigned int&, vw&, boost::program_options::variables_map&, char const*, bool, bool (*)(unsigned int, unsigned int), char const*, char const*)':
search_dep_parser.cc:(.text._ZN6Search12check_optionIjEEvRT_R2vwRN5boost15program_options13variables_mapEPKcbPFbS1_S1_ESA_SA_[_ZN6Search12check_optionIjEEvRT_R2vwRN5boost15program_options13variables_mapEPKcbPFbS1_S1_ESA_SA_]+0x1ea): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::string const&) const'
./libvw.a(search_entityrelationtask.o): In function `EntityRelationTask::initialize(Search::search&, unsigned long&, boost::program_options::variables_map&)':
search_entityrelationtask.cc:(.text+0x33f7): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
./libvw.a(search_graph.o): In function `GraphTask::initialize(Search::search&, unsigned long&, boost::program_options::variables_map&)':
search_graph.cc:(.text+0x17aa): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
search_graph.cc:(.text+0x196c): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::string const&) const'
./libvw.a(scorer.o): In function `scorer_setup(vw&)':
scorer.cc:(.text+0x1cd): undefined reference to `boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)'
scorer.cc:(.text+0x271): undefined reference to `boost::program_options::abstract_variables_map::operator[](std::string const&) const'
collect2: error: ld returned 1 exit status
Makefile:46: recipe for target 'vw' failed
make[1]: *** [vw] Error 1
make[1]: Leaving directory '/home/kapil/Projects/MachineLearning/vowpal_wabbit/vowpalwabbit'
Makefile:97: recipe for target 'vw' failed
make: *** [vw] Error 2

我正在按照存储库中提供的说明进行操作。我已经安装了libboost-program-options-devzlib1g-devlibboost-python-dev。我试图首先运行make,这会给出未定义的引用错误。然后我尝试在make 之前使用autogen.sh 脚​​本,但这也会导致同样的错误。我还尝试使用make BOOST_FLAGS=-lboost-program-optionsmake BOOST_FLAGS=-lboost_options 之类的命令,但未成功。我尝试使用clang++,但输出相同。我已经检查了boostboost_program-options 并且它们都存在并且是最新版本。如何消除错误?

问题是,虽然我可以在 ubuntu 中使用 ppa 安装 vowpalwabbit,但当我尝试使用 pip 为 python 安装它时,它给出了相同的参考错误。我需要安装python版本。

【问题讨论】:

  • 您是否将 -lboost_options 添加到链接器命令行?
  • 我应该在哪里添加? makefile 不是我的,所以请举个例子。

标签: c++ ubuntu boost boost-program-options vowpalwabbit


【解决方案1】:

您遇到的错误表明您没有安装 libboost 开发库(更具体地说,libboost-program-options-dev)。 libboost-program-options-dev 列在从源代码构建 vw 的先决条件中。您可以通过安装元包libboost-all-dev 来安装所有 boost 库+头文件。

根据official instructions in the README.md file,在Ubuntu上不需要运行autogen.sh(事实上,建议不要默认这样做,因为它会覆盖原来的Makefiles 工作得很好)。

这里是完整的 Ubuntu 说明(为方便起见,转载自 github 上的官方 wiki):

Ubuntu/Debian 特定信息

在 Ubuntu/Debian/Mint 和类似情况下,以下顺序应该适用于从 github 构建最新版本:

获取 libboost 程序选项和 zlib:

apt-get install libboost-program-options-dev zlib1g-dev

获取 python libboost 绑定(python 子目录)- 可选:

apt-get install libboost-python-dev

获取大众源码:

git clone git://github.com/JohnLangford/vowpal_wabbit.git

构建:

cd vowpal_wabbit
make
make test       # (optional)
make install

如果这些说明对您不起作用,请确保您没有对您的环境进行其他非标准更改。已知会导致问题的更改是非标准的LD_LIBRARY_PATHLD_RPRELOADldconfig 更改,这可能会导致链接器无法在标准位置找到库。

【讨论】:

    猜你喜欢
    • 2017-01-28
    • 2012-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多