问题1:(.text+0x12): undefined reference to `rpl_fprintf'
解决办法:在yacc前面添加
%{
#undef yyerror
void yyerror (char *s);
%}
在第三部分添加:
void yyerror (char *s) {
fprintf ("%s\n", s);
}
可以解决问题,但是不能错误提示啦!
参看下面的说明之后就可以啦

5: Working around a bison bug

Normally, we'd rely on the bison run-time library to supply a main program, which would invoke the yyparse function and exit when it returned -- essentially, this code:
int main() { yyparse(); return EXIT_SUCCESS; }

To get this automatically, we'd add the -ly option at the end of the command invoking gcc to compile bison's output. As it happens, however, there is currently a bug in the bison library's implementation of the yyerror function, and gcc refuses to deal with it, issuing error messages that look like this:

/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/liby.a(yyerror.o): In function `yyerror':
(.text+0x12): undefined reference to `rpl_fprintf'
collect2: error: ld returned 1 exit status

To work around this, we'll define our own main and yyerror functions. The main we need is the one shown above. yyerror is also elementary:
int yyerror (char const *message)
{
fputs(message, stderr);
fputc('\n', stderr);
return 0;
}
这个比较好!定义为最终解决办法!
Add these function definitions at the appropriate points in your lc.y file.

参看:
http://stackoverflow.com/questions/13073780/error-while-executing-c-file-developed-using-lex-and-yacc-tools
http://pubs.opengroup.org/onlinepubs/7908799/xcu/yacc.html
http://lists.gnu.org/archive/html/help-bison/2011-11/msg00000.html

(.text+0x12): undefined reference to `rpl_fprintf'的更多相关文章

  1. test.cpp:(.text+0xc0): undefined reference to `cv::imread(std::string const&, int)'

    opencv报错: test.cpp:(.text+0xc0): undefined reference to `cv::imread(std::string const&, int)' te ...

  2. clang编译代码报错:`_start': (.text+0x24): undefined reference to `main'

    1. 说明 使用clang++10.1编译报错: /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crt1 ...

  3. 奇 arch/i386/kernel/head.o(.text+0x3e): undefined reference to `stack_start'

    当linux/linkage.h 是dos格式保存,即以\r\n作行结束,gcc-2.96/redhat-7.3报错

  4. ompparticles.cpp:(.text+0x322): undefined reference to `omp_set_num_threads'

    参考 http://www.code-by.org/viewtopic.php?f=54&t=163

  5. tmp/ccdLyHub.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status

    其实就是一个问题,gcc只能编译.c文件,你如果取名为.cpp,那么gcc编译就会就会出现这个错误. 这种情况下: 1.用g++编译(.c 或.c++都可以编译) 2.仍用gcc编译,但是文件后缀改为 ...

  6. (.text+0x18): undefined reference to `main'

    在将VS中的程序移植到ubuntu中出现的一个问题,主要原因是在vs中默认的主函数写成int _tmain(), 而在gcc编译时要找的是int main().改过来就可以了.

  7. gcc参数-l传递顺序错误导致`undefined reference'的一点小结

    刚才编译一个pthread的单文件程序, 使用的命令行是: gcc -o thread1 -lpthread thread1.c 结果报错: $ gcc -o thread1 -lpthread th ...

  8. undefined reference to `switch_dev_unregister'

    编译内核时,使用默认的配置进行编译.出现错误:undefined reference to switch_dev_unregister',undefined reference toswitch_se ...

  9. "undefined reference to" 问题解决方法 -链接问题

    最近在Linux下编程发现一个诡异的现象,就是在链接一个静态库的时候总是报错,类似下面这样的错误: (.text+0x13): undefined reference to `func' 关于unde ...

随机推荐

  1. CSS 中 Font-Family 中英文对照表

    在 CSS 中,我们经常会使用 Font-Family 属性来定义字体.其中,中文字体如果直接使用中文名称,很有可能在非中文的系统环境下造成字体异常.所以通常使用字体的英文名称定义 Font-Fami ...

  2. Spring Cloud集成相关优质项目推荐

    Spring Cloud Config 配置管理工具包,让你可以把配置放到远程服务器,集中化管理集群配置,目前支持本地存储.Git以及Subversion. Spring Cloud Bus 事件.消 ...

  3. JAVA EE的十三种技术

    java ee 的十三中技术 一.jdbc 1). jdbc-odbc桥 2). jdbc-native 驱动桥 3). jdbc-network 桥 4). 纯java驱动 二. java命令和目录 ...

  4. discuz不能发表投票、附件上传等

    如何开启和发表投票主题 本教程主要讲述如何开启和发表投票的帖子.具体的操作如下: 1.论坛后台 => 用户 => 用户组 => 详情 => 特殊主题 => 允许发起投票设 ...

  5. php判断post数据是否存在(or 为空)的方法

    最近开发的php项目用到了表单 所以需要响应post请求 而在实际使用中 有些请求只需判断是否存在 百度了不少资料 发现都比较繁杂 然后想起了  count()函数 — 计算数组中的单元数目或对象中的 ...

  6. Neo4j批量插入(Batch Insertion)

    新建一个maven工程,这里不赘述如何新建maven工程. 添加Neo4j jar到你的工程 有两种方式: 上网站官网下载jar包,根据自己的系统下载不同的压缩包,详细过程不描述,请自行搜索其他博客 ...

  7. SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 的访问

    消息 15281,级别 16,状态 1,第 2 行SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/Open ...

  8. jsp中target="_blank"的用法

    对于点击查询按钮或a标签等,打开一个新页面并显示结果的做法如下: 1.form表单: 在form标签上加target="_blank"后,点击搜索按钮,显示查询结果时会打开一个新页 ...

  9. YII2的增删改查

    insert into table (field1,field2)values('1','2');delete from table where   condition update  table s ...

  10. 关于java中static的应用及一种常见错误

    JAVA中的static的应用 在web项目的开发中,遇到了类中的static方法不奏效. 在开发过程中,我定义了一个静态方法初始化数组,但是在创建类的对象后,访问该数组是全为null.我一直以为st ...