Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix a missing ld library for -lfl while compiling?

I am trying to translate my .spl file into a C file (because there is no compiler). I have an example "Hello World" .spl file, and I have downloaded the Shakespeare Programming Language .tar and extracted it, but I have no idea what to do next. I can't seem to find instructions in any documentation. Can anyone help?

Edit:

When I type make -f "Makefile", I get the following output:

bison --verbose -d grammar.y
gcc -O2 -Wall -c grammar.tab.c
gcc -O2 -Wall -c makescanner.c
gcc makescanner.o -O2 -Wall -o makescanner
./makescanner include > scanner.l
flex -Cem -t scanner.l > scanner.c
scanner.l:600: warning, rule cannot be matched
gcc -O2 -Wall -c scanner.c
<stdout>:5823: warning: ‘yyunput’ defined but not used
gcc -O2 -Wall -c strutils.c
gcc grammar.tab.o scanner.o strutils.o -O2 -Wall -lfl -o spl2c
ld: library not found for -lfl
collect2: ld returned 1 exit status
make: *** [spl2c] Error 1
like image 555
Skyler Avatar asked Apr 17 '13 02:04

Skyler


People also ask

How do you resolve usr bin Ld Cannot find?

To resolve this problem, you should either provide the library file ( lib{nameOfTheLibrary}. so ) in those search paths or use -L command option. -L{path} tells the g++ (actually ld ) to find library files in path {path} in addition to default paths.

What is my LD_ LIBRARY_ PATH?

LD_LIBRARY_PATH tells the dynamic link loader (ld. so – this little program that starts all your applications) where to search for the dynamic shared libraries an application was linked against.

What is LD in Ld_library_path?

LD_LIBRARY_PATH - stands for LOAD LIBRARY PATH or some times called as LOADER LIBRARY PATH.


1 Answers

The problem is that the Authors decided to link their program against the mostly useless libfl library, which is almost never needed, so not included in some flex distributions (in particlar, the one on MacOS).

It turns out that libfl only has two functions defined in it -- main and yywrap. The main in libfl is pretty much never used, and the yywrap might as well not be, because all it does is return 1.

It turns out you can fix the code easily enough:

  1. edit the file include/user_code_top.metaflex and add the line %option noyywrap to the end.

  2. edit the Makefile and remove the -lfl from the link line (just search for the string -lfl and remove those 4 characters wherever they appear)

Now you should be able to build it (though you may need to delete the file scanner.l if you previously ran make and got the failure, as the Makefile fails to detect that it need to be rebuilt after editing the metaflex file).

like image 174
Chris Dodd Avatar answered Oct 09 '22 01:10

Chris Dodd