Trouble building gcc 4.6: undefined reference to `yylex'

本秂侑毒 提交于 2019-12-03 06:36:19

问题


I'm trying to build gcc 4.6, but I'm getting some linker errors that look like it means bison or flex isn't getting linked to. When the makefile issues this command:

gcc   -g -fkeep-inline-functions -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/gengtype \
        build/gengtype.o build/errors.o build/gengtype-lex.o build/gengtype-parse.o build/version.o ../../build-x86_64-unknown-linux-gnu/libiberty/libiberty.a

It tells me:

/home/chris/code/gcc/trunk/host-x86_64-unknown-linux-gnu/gcc/../.././gcc/gengtype.c:960: undefined reference to `lexer_line'
... undefined reference to `yylex'
... undefined reference to `yybegin'
... undefined reference to `yyend'

I've installed Flex and Bison, and even tried several Bison variants with the same result. Does anybody know what else this might mean?


回答1:


Same happened to me, it was due to lack of flex and bison. After installing flex and bison, I ran make distclean and ./configure, then it compiled fine.




回答2:


Ran into this as well but the fix for me was to install bisonc++, for whatever reason I only had bison installed.




回答3:


It just got into some weird state since I did ./configure and tried to build it before having bison and flex set up properly. Calling make clean wasn't enough. I wiped out the whole thing and did a fresh checkout and it builds fine now.



来源:https://stackoverflow.com/questions/4262531/trouble-building-gcc-4-6-undefined-reference-to-yylex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!