问题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. linux查看一条命令的执行结果是1还是0

    echo $? 0为成功 其他为失败

  2. win7系统下的FTP配置

    2016-07-12 工作中需要在win7操作系统下配置FTP,遇到许多问题,所以记录下来方便以后解决问题. FTP是文件传输协议的简称.用于Internet上的控制文件的双向传输.同时,它也是一个应 ...

  3. 09——绝不在构造和析构函数中调用virtual函数

    在base class构造期间,virtual函数不是virtual函数. 构造函数.析构函数中不要调用virtual函数.

  4. 数据库和3G的结合使用

    // //  设备数据管理类 #import <Foundation/Foundation.h> #import "DeviceInfo.h" @interface D ...

  5. 解决织梦DEDEcms指定arclist的特定ID排序的方法

    转载网址:http://blog.hrseo.net/xuexi/184.html 替换/include/taglib/arclist.lib.php这个文件,下载链接: http://pan.bai ...

  6. iOS 崩溃日志 Backtrace的符号化

    iOS的崩溃日志配合dsym文件可以找到崩溃时的backtrace,这是解决崩溃的最重要的信息. 如果是在同一台mac上打包, 导入crash log时候会自动将backtrace符号化,可以看到方法 ...

  7. SQL --Chapter02 查询基础

    SELECT 语句基础 SELECT <列名>,….. FROM <表名>; 查询全部列: SELECT * FROM <表名>; 使用AS关键字为列设置别名,设定 ...

  8. hhvm之轻进程

    本文为原创,转载请注明:http://www.cnblogs.com/gistao/ 背景 我们在aws上部署了hhvm,高峰段发现cpu idle降的比较低,只有10-20%,而使用php-fpm的 ...

  9. pthread_create 内存释放

    run() { pthread_attr_destroy(&m_attr);    pthread_detach(pthread_self()); }

  10. 05_动手动脑之String.equals()方法的实现代码

    Question: 请查看String.equals()方法的实现代码,注意学习其实现方法. Answer: java中的String.equals()方法的实现代码: equals()法是根类Obj ...