在 Boost 库 (program_options) 中编译失败
Compilation fail in Boost librairies (program_options)
今天我重建了我的C++应用程序,编译失败了。不过,一切都没有改变。第一个错误是在我的类List
中,它继承自这里的std::vector
(私有继承):
template<typename T> void List<T>::append(const T& value)
{
push_back(value);
}
我必须在push_back(value);
之前添加std::vector<T>::
,因为编译器找不到任何声明。我真的不知道为什么会这样,但是有一个 g++ 的更新,我现在使用 g++ v4.7.0(预发行版)在 Arch Linux 上使用 C++11。
我解决了这个问题,但现在真正的问题是,由于 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 类相同的错误...
谢谢!
我怀疑您已经被 gcc 4.7 中模板实例化的两阶段查找规则的变化所困扰。
如果没有源代码,我无法给出更实用的建议,但是 gcc4.7 更改(第 C++ 章)给出了两阶段查找的描述,并提出了一些代码更正建议。
相关文章:
- 包含模板文件的递归会导致编译失败
- 提升 1.64 单元测试编译失败
- C++模板的模板编译失败
- 使用已删除的函数进行编译失败,并显示 uclibc
- MinGW-w64 编译失败,nullptr_t
- 使用提升线程时编译失败
- 编译花絮 g++, clang++, 使用 libboost -- g++8 编译失败时 g++7 成功;
- CMake + Qt,moc 编译失败,无法实现 QMetaObject 方法(编译器找不到基本 ui 对象的标头?
- 带有引用的std::tuple在clang中编译失败,但在gcc中编译失败
- 解决由于在哈希函数中使用了不完整的类型而导致的编译失败
- 将XCode升级到verison 11.1后,C++编译失败
- 添加类型名会导致程序编译失败
- 将 qi::lexeme 添加到灵气中的规则时编译失败
- 如果我在下面的代码中使用 list 而不是 vector,为什么在我尝试在迭代器之间执行减法的行中编译失败?
- 返回 std::stringstream - 编译失败
- 编译失败:strlen 不是 std 的成员
- MSBuidel - 将资源文件添加到项目后静态库编译失败
- C++ - 在 std::thread 中调用重载函数时编译失败
- QtWebEngine 到嵌入式 Linux 交叉编译失败
- 使用 glibc 2.7 包含路径编译失败