Page 1 of 1

Error building cross-compiler (undefined reference to yylex)

Posted: Sat Feb 14, 2015 1:31 am
by ostylk
Hey,
I've wanted to follow the baby steps tutorial to build a hello world kernel. So I started to build my cross-compiler, the binutils compiled fine(version 2.22) then I wanted to build gcc(version 4.6.4) my system's compiler version was 4.6.3. But when I ran make all-gcc I've got this error:

Code: Select all

build/gengtype.o: In function `adjust_field_type':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype.c:1264: undefined reference to `lexer_line'
build/gengtype.o: In function `adjust_field_rtx_def':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype.c:978: undefined reference to `lexer_line'
build/gengtype.o: In function `adjust_field_type':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype.c:1279: undefined reference to `lexer_line'
build/gengtype.o: In function `adjust_field_tree_exp':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype.c:1205: undefined reference to `lexer_line'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype.c:1217: undefined reference to `lexer_line'
build/gengtype.o:/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype.c:1032: more undefined references to `lexer_line' follow
build/gengtype-parse.o: In function `token':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
build/gengtype-parse.o:/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: more undefined references to `yylex' follow
build/gengtype-parse.o: In function `type':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:722: undefined reference to `lexer_line'
build/gengtype-parse.o: In function `token':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
build/gengtype-parse.o: In function `type':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:793: undefined reference to `lexer_line'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:793: undefined reference to `lexer_line'
build/gengtype-parse.o: In function `token':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
build/gengtype-parse.o: In function `type':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:754: undefined reference to `lexer_line'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:754: undefined reference to `lexer_line'
build/gengtype-parse.o: In function `token':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
build/gengtype-parse.o:/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: more undefined references to `yylex' follow
build/gengtype-parse.o: In function `struct_field_seq':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:688: undefined reference to `lexer_line'
build/gengtype-parse.o: In function `token':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
build/gengtype-parse.o: In function `type':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:778: undefined reference to `lexer_line'
build/gengtype-parse.o: In function `token':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
build/gengtype-parse.o:/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: more undefined references to `yylex' follow
build/gengtype-parse.o: In function `parse_file':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:947: undefined reference to `yybegin'
build/gengtype-parse.o: In function `token':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
build/gengtype-parse.o: In function `parse_file':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:982: undefined reference to `lexer_toplevel_done'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:987: undefined reference to `yyend'
build/gengtype-parse.o: In function `extern_or_static':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:888: undefined reference to `lexer_line'
build/gengtype-parse.o: In function `def_vec':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:914: undefined reference to `lexer_line'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:915: undefined reference to `lexer_line'
build/gengtype-parse.o: In function `def_vec_alloc':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:939: undefined reference to `lexer_line'
build/gengtype-parse.o: In function `typedef_decl':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:838: undefined reference to `lexer_line'
build/gengtype-parse.o: In function `token':
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
/home/ostylk/src/build-gcc/gcc/../../gcc_4_6_4_release/gcc/gengtype-parse.c:49: undefined reference to `yylex'
After some googling I've found out that the error occurs because of flex, my flex version is 2.5.39. I've tried to install some other flex version(2.5.35, 2.5.37, 2.5.4a) but it doesn't work I got the same error. Does anybody know where the problem could be?

P.S. My linux distribution is: Elementary OS Luna (version: 0.2, 64-bit)

Re: Error building cross-compiler (undefined reference to yy

Posted: Sat Feb 14, 2015 5:07 am
by ExeTwezz
GCC prerequisites wrote:Flex version 2.5.4 (or later)
Necessary when modifying *.l files.
Necessary to build GCC during development because the generated output files are not included in the SVN repository. They are included in releases.
ostylk wrote:I've tried to install some other flex version(2.5.35, 2.5.37, 2.5.4a)
Try compiling with Flex >= 2.5.4 installed.
Though I've Flex 2.5.35 installed, I've successfully compiled i686-elf-gcc 4.9.2.

See other deps at https://gcc.gnu.org/install/prerequisites.html.

Also, why don't you compile the newer versions of binutils and GCC? For example, binutils 2.24 and GCC 4.9.2.

Re: Error building cross-compiler (undefined reference to yy

Posted: Sat Feb 14, 2015 10:18 am
by ostylk
Hey,
I've downloaded the gcc_4_9_2_release and tried to compile/build it again. The error with that "yylex" disappeared but now I get another error when running:
make all-target-libgcc

Code: Select all

checking for i686-elf-gcc...  /home/ostylk/src/build_gcc/./gcc/xgcc -B/home/ostylk/src/build_gcc/./gcc/ -B/usr/local/cross/i686-elf/bin/ -B/usr/local/cross/i686-elf/lib/ -isystem /usr/local/cross/i686-elf/include -isystem /usr/local/cross/i686-elf/sys-include   
checking for suffix of object files... configure: error: in `/home/ostylk/src/build_gcc/i686-elf/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make: *** [configure-target-libgcc] Error 1
I looked into config.log but there seems to be no error logged...
I've already tried to edit the LD_LIBRARY_PATH with the export command to tell where my mpc, mpfr and gmp libraries are but it doesn't work I get the same error. I used that download_prerequisites script in the contrib folder of the gcc release and downloaded with it all of the libraries. After that he is still not compiling/building gcc again with the same error.
Also I've tried to add to the configure command the parameter -v but this doesn't work as well...
But the make target: make all-gcc and make install-gcc works without error.
Here is the config.log: http://pastebin.com/BGW7UAu5

Re: Error building cross-compiler (undefined reference to yy

Posted: Sun Feb 15, 2015 7:15 am
by ExeTwezz
ostylk wrote:I've already tried to edit the LD_LIBRARY_PATH with the export command to tell where my mpc, mpfr and gmp libraries are but it doesn't work I get the same error. I used that download_prerequisites script in the contrib folder of the gcc release and downloaded with it all of the libraries. After that he is still not compiling/building gcc again with the same error.
As Wikipedia says, Elementary OS is Ubuntu based, so you can easily follow the tutorial on wiki.osdev.org. Don't compile gmp, mpfr, mpc and texinfo, just download them using apt-get (though you can do that). Also, cloog, as I remember from my exp, may cause problems while compiling (but it may be only on my system).

Re: Error building cross-compiler (undefined reference to yy

Posted: Sun Feb 15, 2015 7:36 am
by Octocontrabass
ExeTwezz wrote:Also, cloog, as I remember from my exp, may cause problems while compiling (but it may be only on my system).
CLooG fails to compile if you use ISL newer than 0.12.2.

GCC 5 will remove the dependency on CLooG.