问题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. GTC China 2016观感

    上周二在北京参加了GTC China 2016,最大的感受就是一个字,“冷”!黄教主一如既往坚持机车皮夹克装,9月中旬的北京还没有那么的冷啊,感觉全场的空调简直是为他而开...好的,以上吐槽完毕,接着 ...

  2. Mysql修改日期,时间不变的做法

    UPDATE tra_bargainorder SET EndParkingTime = ADDTIME (CURDATE() + INTERVAL 0 HOUR,TIME(EndParkingTim ...

  3. jQuery的选择器中的通配符总结

    1.选择器 (1)通配符: $("input[id^='code']");//id属性以code开始的所有input标签 $("input[id$='code']&quo ...

  4. 嵌入式linux应用程序移植方法总结

    嵌入式linux应用程序移植方法总结 前段时间一直在做openCapwap的移植和调试工作,现在工作已接近尾声,编写本文档对前段工作进行一个总结,分享下openCapwap移植过程中的经验和感悟.江浩 ...

  5. kindeditor本地上传报错,只限初学者

    困扰了我三天的问题,话说百度真的害死人啊,百度上有说路劲错了的,有说包没导的,有说还要改plugins里面的文件的!其实这个都不用动,也有说服务器问题的,还有说缓存的,还有说是ecplise的,反正我 ...

  6. 2015.10.15class

    #include<stdio.h> main() { int a; printf("你的智商是多少?\n"); scanf("%d",&a) ...

  7. php 斐波那契数列

    function fib($n) { $cur = 1; $prev = 0; for ($i = 0; $i < $n; $i++) { yield $cur; $temp = $cur; $ ...

  8. MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 的解决办法和原因

    这两天下载了MySQL5.7.11进行安装,发现到了初次使用输入密码的时候,不管怎样都进不去,即使按照网上说的在mysqld 下面添加skip-grant-tables也是不行,后来研究了两天,终于找 ...

  9. MediaCodec Name & Type

    OMX.google.mp3.decoder support type:audio/mpegOMX.google.amrnb.decoder support type:audio/3gppOMX.go ...

  10. Linux中的入口函数main

    main()函数,想必大家都不陌生了,从刚开始写程序的时候,大家便开始写main(),我们都知道main是程序的入口.那main作为一个函数,又是谁调用的它,它是怎么被调用的,返回给谁,返回的又是什么 ...