Boost Spirit x3 示例计算器(calc8、calc9)链接器错误

2023-12-03

我对提升精神(以及提升)非常陌生。它非常有趣的图书馆。

我使用 qtcreator + MinGW 5.3。 我只是添加每个源文件git_hub_calc8进入新项目并添加一些 boost 库,但我在尝试构建时遇到以下错误(所有其他示例都工作正常)

C:\Program Files\boost\boost\boost\spirit\home\x3\nonterminal\rule.hpp:113: ошибка: undefined reference to `bool client::parser::parse_rule<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::spirit::x3::context<boost::spirit::x3::error_handler_tag, std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const, boost::spirit::x3::unused_type> >, std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> > >(boost::spirit::x3::rule<client::parser::statement_class, std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >, false>, __gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&, __gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, boost::spirit::x3::context<boost::spirit::x3::error_handler_tag, std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const, boost::spirit::x3::unused_type> > const&, std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >&)'

我做错了什么?我应该如何用这个例子创建项目?

似乎 BOOST_SPIRIT_DECLARE 有问题,因为错误指出的地方是调用与此定义连接的模板函数

(template <typename Iterator, typename Context, typename Attribute_>
        bool parse(Iterator& first, Iterator const& last
          , Context const& context, unused_type, Attribute_& attr) const
        {
            return parse_rule(*this, first, last, context, attr);
        }

The BOOST_SPIRIT_INSTANTIATEmarco 相当于做

namespace client { namespace parser
{

    template bool parse_rule<iterator_type, context_type, statement_type::attribute_type>(
        statement_type rule_, iterator_type &first, iterator_type const &last,
        context_type const &context,
        statement_type ::attribute_type &attr);
                                                                        ;
}}

所以关键的一点是iterator_type and context_type match exactly呼叫站点所需的那些。现在,未解析的符号是(已分解):

bool client::parser::parse_rule<
    __gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >,
    boost::spirit::x3::context<
        boost::spirit::x3::error_handler_tag,
        std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<
            char const *, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >,
        boost::spirit::x3::context<
            boost::spirit::x3::skipper_tag,
            boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const,
            boost::spirit::x3::unused_type> >,
    std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >
>
(boost::spirit::x3::rule<client::parser::statement_class, std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >, false>,
__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >&,
__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&,
    boost::spirit::x3::context<
        boost::spirit::x3::error_handler_tag,
        std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<
            char const *, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >,
        boost::spirit::x3::context<
            boost::spirit::x3::skipper_tag,
            boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const,
            boost::spirit::x3::unused_type> > const &,
std::__cxx11::list<client::ast::statement, std::allocator<client::ast::statement> >&)

这意味着 iterator_type 应该是:

__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >,

这确实是什么std::string::const_iterator扩展到我的系统上。因此,上下文类型可能不匹配。通过在上面添加强制类型错误BOOST_SPIRIT_INSTANTIATE像这样调用:

struct {} _ = *static_cast<client::parser::context_type*>(nullptr);

我能够强制编译器输出扩展类型context_type在实例化点:

statement.cpp:12 error: conversion from ‘client::parser::context_type {aka boost::spirit::x3::context<boost::spirit::x3::error_handler_tag, const std::reference_wrapper<boost::spirit::x3::error_handler<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >, boost::spirit::x3::context<boost::spirit::x3::skipper_tag, const boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag>, boost::spirit::x3::unused_type> >}’ to non-scalar type ‘client::parser::<anonymous struct>’ requested

这告诉我们上下文类型是(为了易读而格式化):

boost::spirit::x3::context<
    boost::spirit::x3::error_handler_tag,
    const std::reference_wrapper<boost::spirit::x3::error_handler<
        __gnu_cxx::__normal_iterator<const char *, std::__cxx11::basic_string<char> > > >,
    boost::spirit::x3::context<
        boost::spirit::x3::skipper_tag,
        boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const,
        boost::spirit::x3::unused_type> >,

但是:链接器将其作为

boost::spirit::x3::context<
    boost::spirit::x3::error_handler_tag,
    std::reference_wrapper<boost::spirit::x3::error_handler<
        __gnu_cxx::__normal_iterator<const char *, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >,
    boost::spirit::x3::context<
        boost::spirit::x3::skipper_tag,
        boost::spirit::x3::char_class<boost::spirit::char_encoding::ascii, boost::spirit::x3::space_tag> const,
        boost::spirit::x3::unused_type> >

最明显的区别在于默认模板参数的拼写std::basic_string (char_traitsallocator),但这实际上没有区别。然而,真正重要的区别是缺乏constreference_wrapper<> type.

修复它

我想这可能是X3历史上曾经的一次改变。在这种情况下,最简单的解决方法是删除const在config.hpp中:

typedef x3::context<
    error_handler_tag
  , std::reference_wrapper<error_handler_type>
  , phrase_context_type>
context_type;

事实上,它现在可以编译了

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Boost Spirit x3 示例计算器(calc8、calc9)链接器错误 的相关文章

  • 使用 boost 几何检查两条线是否有交点

    是否可以使用 boost geometry 检查两条线段 每条线段由二维中的两个点给出 是否彼此相交 如果可能的话 boost geometry 是否还允许检查特殊情况 例如另一条线上只有一个点 数字上 或者两条线相等 如果你具体谈论Boo
  • boost::serialization 序列化期间内存消耗较高

    正如主题所示 在将大量数据序列化到文件时 我遇到了 boost serialization 的一个小问题 问题在于应用程序序列化部分的内存占用量大约是要序列化的对象内存的 3 到 3 5 倍 值得注意的是 我拥有的数据结构是基类指针和指向该
  • [现代] C++ 中 N 个变量的范围/循环

    遍历 N 个任意类型的变量来执行操作的简洁方法是什么 假设我有变量a b c d e并想要对他们所有人进行一些操作 使用 Boost Hana 和通用 lambda include
  • 升压参数库

    最近我发现参数 http www boost org doc libs 1 50 0 libs parameter doc html index htmlBoost 中的库 老实说 我不明白为什么这是 Boost 的一部分 当需要向函数传递
  • Xcode 4 上的 Boost 库静态链接

    我在 OS X 上使用 Xcode 使用 Boost 库 Boost 使用 macports 安装在我的系统上 通过将我需要的 3 个 boost 库 例如 libboost thread mt a 添加到 Targets Link Bin
  • 错误LNK2001:无法解析的外部符号公共:静态类[重复]

    这个问题在这里已经有答案了 我不明白为什么我会收到这个错误 任何人都可以伸出援手吗 我需要在头文件中声明VideoCapture捕获并在Video cpp中调用它 Video h class Video public static Vide
  • 使用 Boost program_options 指定级别(例如 --verbose)

    我的一些选择有多个级别 例如的 冗长 我希望我的用户在以下两种等效样式之间进行选择 no argument verbosity of 1 my program v count the v s verbosity of 4 my progra
  • 提升shared_from_this<>()

    有人可以用几句话概括一下如何提升shared from this lt gt 应该使用智能指针 特别是从使用绑定函数在 io service 中注册处理程序的角度来看 编辑 一些回复要求提供更多背景信息 基本上 我正在寻找 陷阱 即人们使用
  • 信号与信号2

    我的应用程序可能会受益于使用 boost 的信号库之一而不是本土解决方案 该应用程序是多线程的 但执行信号处理的部分是单线程的 如果多线程不是问题 是否有任何理由更喜欢 Boost Signals2 而不是 Boost Signal Boo
  • RestKit链接器错误

    我一直遵循 RestKit 安装说明 但现在在尝试构建应用程序时出现错误 这是针对 ios iPad 的 我收到 命令 Developer Platforms iPhoneSimulator platform Developer usr b
  • 使用 Boost:Asio 的游戏服务器如何异步工作?

    我正在尝试创建一个游戏服务器 目前我正在使用线程来制作它 每个对象 玩家 怪物 都有自己的带有 while 1 循环的线程 在其中执行特定的功能 服务器基本上是这样工作的 main some initialization while 1 r
  • 如何将带有自定义分配器的 std::vector 传递给需要带有 std::allocator 的函数?

    我正在使用外部库 pcl 因此我需要一个不会更改现有函数原型的解决方案 我正在使用的一个函数生成一个std vector
  • 使用 boost 异步发送和接收自定义数据包?

    我正在尝试使用 boost 异步发送和接收自定义数据包 根据我当前的实现 我有一些问题 tcpclient cpp include tcpclient h include
  • Xcode 10 Beta 5 — clang:错误:链接器命令失败,退出代码为 1

    有人可以帮我吗 我的项目一切正常 但更新到 Xcode10 Beta5 后 尝试在 iPhone 上运行该应用程序时出现此错误 然而模拟器可以工作 请帮助我 我已经对这个问题进行了网络搜索并发现this https stackoverflo
  • 在 Xcode4 中使用 Boost

    有人设置 C Xcode4 项目来使用 Boost 吗 对于一个简单的 C 控制台应用程序 我需要在 Xcode 中设置哪些设置 Thanks 用这个来管理它 和这个
  • C++ 是否可以在 MacOS 上与 OpenMP 和 boost 兼容?

    我现在已经尝试了很多事情并得出了一些结论 也许 我监督了一些事情 但似乎我无法完成我想要的事情 问题是 是否有可能使用 OpenMP 和 boost 在 MacOS High Sierra 上编译 C 一些发现 如果我错了请纠正我 Open
  • 如何使用 c++ libboost 运行进程并获取其输出?

    我正在尝试运行外部 shell 命令并使用 C 的 Boost 库读取其输出 但似乎该命令未运行或我无法访问输出 我在用着他们的文档 https www boost org doc libs 1 65 1 doc html boost pr
  • 用于建模一般树结构及其迭代器的智能指针

    我通过为每个节点建立一个类来建模一般树结构 该类包含指向父级 第一个子级和第一个兄弟级的指针 以及指向最后一个兄弟级的指针 不需要 但有用 为此 我添加了一些额外的数据 我目前的实现是 class TreeNode typedef boos
  • 在生产者-消费者情况下使用条件变量

    我正在尝试了解条件变量以及如何在生产者 消费者情况下使用它 我有一个队列 其中一个线程将数字推入队列 而另一个线程从队列中弹出数字 当生产线程放置一些数据时 我想使用条件变量向消费线程发出信号 问题是有时 或大多数时候 它只将最多两个项目推
  • 使用 boost::lexical_cast 将 UUID 转换为字符串时出现 Boost 编译错误

    我有这个代码 它基于 SO 中的几篇文章 boost uuids uuid uuid boost uuids random generator auto uuidString boost lexical cast

随机推荐

  • Symfony CollectionType 更新实体

    我不敢相信其他人没有遇到这种情况 但我无法找到解决方案 假设我有两个实体类型 A 和 B 具有一对多关系 A 有 B 的集合 A 的形式有一个CollectionType对于B 有一个定制的entry type for B allow ad
  • 在高性能环境中的分叉工作进程之间共享状态

    这是我的后续行动上一个问题 正如 Tim Peters 所建议的 使用Manager可能不一定是最好的方法 不幸的是我有太多的脚手架代码来发布SSCCE 相反 我将尝试提供我的问题的详细解释 请随意浏览整个代码库Github 但现在有点混乱
  • 如何使用vba for excel获取另一个工作簿中定义名称的值

    我有几本包含计算的工作簿 我正在将所有这些工作表中的数据结合起来进行 自动概述 为了查找数据 我使用命名范围 这些工作正常 然而 有一个定义的名称不涉及范围 这是一个公式 我想要的是访问该公式的结果 以open计算书 来自我的概述书 明显地
  • RxJava:“java.lang.IllegalStateException:仅允许一名订阅者!”

    我正在使用 RxJava 来计算 Android 中某些传感器数据的归一化自相关性 奇怪的是 我的代码抛出一个异常 java lang IllegalStateException 只允许一个订阅者 我不确定该怎么做 我知道 GroupedO
  • 将图像从 URL 保存到服务器

    我建立了一个迷你内容管理系统CKEditor 用户可以粘贴图像URL来自另一个网站 有没有办法在用户提交内容时获取所有图像 URL 将所有这些图像保存到服务器 并用我的服务器的 URL 替换其他服务器的 URL 例如 用户写了这样的内容 i
  • Kivy - 通过 id 删除小部件

    我有以下代码 from kivy app import App from kivy uix floatlayout import FloatLayout class GUI FloatLayout def remove self self
  • 导入错误:没有名为plotly.plotly的模块

    我正在处理项目并收到此错误 导入错误 没有名为plotly plotly的模块 I tried pip 情节安装 pip install plotly 升级 But import plotly plotly as py没用 不知道pyzo
  • 一次将 100 个文本文件导入 Excel

    我有这个宏可以在 Excel 电子表格中批量导入同一文件夹中包含的 100 多个 txt 文件 Sub QueryImportText Dim sPath As String sName As String Dim i As Long qt
  • FileUpload1.HasFile 为 False

    我尝试在网上搜索这个问题 发现大家都在询问UpdatePanel内的FileUpload控件的问题 首先 我没有使用 UpdatePanel 下面是我的代码 HTML
  • ImportError:运行从 pyinstaller 获取的可执行文件时没有名为 Geometry 的模块

    Traceback most recent call last File
  • odoo 中的 Many2one 字段的域过滤器?

    下面的代码是资产继承类 这里我要补充一下 place 场与 卡恩 邦 肯杰里 and 卡恩 邦 马勒什瓦拉姆 对于 Karn Bang Kengeri 将添加带有 A 和 B 的 asset catg id 然后对于 karn bang m
  • MySQL GROUP 和 COUNT 多个表

    我有一个由 3 部分组成的问题 这给我带来了麻烦 如果我查询 1 个表 我知道如何让表正常工作 一次但我似乎不知道如何将两者结合起来tags and more tags表以获得相同的结果 下面列出了我遇到的 3 个主要问题 问题1 我希望能
  • 如果React.js是MVC中的V,那么其他字母是什么?

    我正在学习 React 但我仍然不确定如何将其发展为成熟的应用程序 对于 M 和 C 哪些框架很适合使用 如果我想发挥功能怎么办 我应该只使用 jQuery 吗 路由 Ajax 以及许多框架为我们提供的其他功能怎么样 你实际上可以简单地去F
  • 为什么我不能在另一个函数中定义一个函数?

    这不是 lambda 函数问题 我知道我可以将 lambda 分配给变量 允许我们在代码中声明但不定义函数有什么意义 例如 include
  • Rails db:迁移关系不存在

    我有这样的模型 学生 class Student lt ActiveRecord Base has many participations dependent destroy has many subject item notes depe
  • setbuf() 会影响 cout 吗?

    我的老师再次无法回答我的问题 我知道谁能够 所以 我从来没有真正学过 C 在 C 中 显然我一直都会使用 cout 语句 在最近的一次作业中 我的老师告诉我们要确保 setbuf stdout NULL 在 main 的顶部以获得无缓冲的输
  • 如何获取属性文件的路径并在运行时将其传递给 bean

    我有一个由 Spring 创建的 bean 实际的类驻留在与 Spring 不同的 JAR 中 该 bean 传递一个路径作为构造函数参数 但是 我很难检索文件的句柄 该文件位于 WEB INF classes 中 我尝试过基于 WEB I
  • Unix“查找”命令用法

    这是一个 bash 安装脚本 脚本 foo sh 将 DIRECTORY 作为参数 说 有一个目录 lt HOME gt TEST TEST 1A TEST 2A TEST 3和另一个目录 lt HOME gt TEST TEST 1B T
  • PostgreSQL 或 MySQL 中的默认选择顺序是什么?

    我在 PostgreSQL 文档中读到 如果没有 ORDER 语句 SELECT 将以未指定的顺序返回记录 最近在一次采访中 有人问我如何按照插入的顺序 SELECT 记录 而无需 PK 或created at 或其他可用于排序的字段 采访
  • Boost Spirit x3 示例计算器(calc8、calc9)链接器错误

    我对提升精神 以及提升 非常陌生 它非常有趣的图书馆 我使用 qtcreator MinGW 5 3 我只是添加每个源文件git hub calc8进入新项目并添加一些 boost 库 但我在尝试构建时遇到以下错误 所有其他示例都工作正常