【问题标题】:Compilation fail in Boost librairies (program_options)Boost 库中的编译失败 (program_options)
【发布时间】:2012-04-04 22:29:31
【问题描述】:

今天我重建了我的 C++ 应用程序,但编译失败。什么都没有改变。第一个错误出现在我的类List 中,它继承自std::vector(私有继承):

template<typename T> void List<T>::append(const T& value)
{
    push_back(value);
}

我不得不在push_back(value); 之前添加std::vector&lt;T&gt;::,因为编译器没有找到任何声明。我真的不知道为什么会这样,但是 g++ 有一个更新,我现在在 Arch Linux 上使用 C++11 使用 g++ v4.7.0 (prerelease)。

我解决了这个问题,但现在真正的问题是,由于 Boost 库 program_options 中的问题,我无法编译应用程序的其余部分。我将库包含在:

#include <boost/config.hpp>
#include <boost/program_options/detail/config_file.hpp>
#include <boost/program_options/parsers.hpp>

错误:

g++ -m64 -pipe -pedantic -Wextra -std=gnu++0x   -c -g -Wall -DDEBUG -DDEV -DMYSQL_SUPPORT -I. -IHeaders -MMD -MP -MF build/Debug/GNU-Linux-x86/Sources/Libs/Settings.o.d -o build/Debug/GNU-Linux-x86/Sources/Libs/Settings.o Sources/Libs/Settings.cpp
/usr/include/boost/program_options/detail/config_file.hpp: In instantiation of ‘bool boost::program_options::detail::basic_config_file_iterator<charT>::getline(std::string&) [with charT = char; std::string = std::basic_string<char>]’:
In file included from Sources/Libs/Settings.cpp:33:0:
Sources/Libs/Settings.cpp:69:24:   required from here
/usr/include/boost/program_options/detail/config_file.hpp:163:13: erreur: ‘to_internal’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
In file included from /usr/include/boost/program_options/detail/parsers.hpp:9:0,
                 from /usr/include/boost/program_options/parsers.hpp:265,
                 from Sources/Libs/Settings.cpp:34:
/usr/include/boost/program_options/detail/convert.hpp:75:34: note: ‘template<class T> std::vector<std::basic_string<char> > boost::program_options::to_internal(const std::vector<T>&)’ declared here, later in the translation unit

与我的 List 类相同的错误......

谢谢!

【问题讨论】:

    标签: c++ boost c++11 g++ boost-program-options


    【解决方案1】:

    我怀疑您已经被 gcc 4.7 中模板实例化的两阶段查找规则的变化所困扰。

    如果没有源代码,我无法给出更实用的建议,但gcc4.7 changes(C++ 章)描述了两阶段查找并提出了一些代码更正建议。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多