mbornet-hl / hl

Highlight (colorize) text data using regular expressions (efficient C program)
Other
118 stars 9 forks source link

Undefined reference to yyin and yylex but flex is installed #16

Closed ASL07 closed 4 years ago

ASL07 commented 4 years ago

Hi, thanks for your great tool!

I am having some errors compiling on Ubuntu server. Hope you can have a look:

OS version

uname -a
Linux  4.15.0-109-generic #110-Ubuntu SMP Tue Jun 23 02:39:32 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

I have installed flex package version 2.6.4

lex -V
flex 2.6.4

But I get the following errors when running make:

make[1]: Entering directory '/usr/src/hl/src'
cr_main.o: In function `cr_read_config_file':
cr_main.c:(.text+0x182): undefined reference to `yyin'
cr_main.c:(.text+0x189): undefined reference to `yyin'
cr_main.c:(.text+0x1e2): undefined reference to `yylex'
collect2: error: ld returned 1 exit status
Makefile:18: recipe for target 'hl' failed
make[1]: *** [hl] Error 1
make[1]: Leaving directory '/usr/src/hl/src'
Makefile:6: recipe for target 'hl' failed
make: *** [hl] Error 2

Thanks

mbornet-hl commented 4 years ago

Hi, I'm glad you appreciate this command, thanks for your message.

I've just compiled hl in an Ubuntu VM (19.10) using flex 2.6.4, and I had no problem to compile it : mb@vm-ubuntu-19:~/hl/src$ make cc -c -o cr_main.o cr_main.c cc -c -o cr_gpri.o cr_gpri.c lex -t cr_lex.l > cr_lex.c cc -c -o cr_lex.o cr_lex.c ./hl: version 1.93

Do you have additional error messages to give me that could better show the problem you encounter ? What version of Ubuntu do you use exactly ? Thanks.

mbornet-hl commented 4 years ago

Hi, do you still have problems with the compilation, or may I close this issue ?

mbornet-hl commented 4 years ago

Hi, it's been more than one month now that I answered your mail. Since I've got no more message from you, I close this issue. If you need additional information, feel free to re-open it. Thanks. Regards,

Martial

epiciskandar commented 2 years ago

For anyone may referenced to this issue, the most possible reason is:

  1. run make without lex installed, then you may installed it via package mgr like apt or dnf etc.
  2. run make again with flex installed. but in step 1 the Makefile already created an empty cr_lex.c file, and the make didn't give a shxt on it, make just works and generate dry zombie cr_lex.o
  3. ld complains

so, the solution is: rm cr_lex.c && make clean && make