Need help to compile my flex project #156735
-
BodyHello, I need some help please !I'm trying to compile a school project in flex on my Mac but I can't find what's causing the error I get. Here what I got :
Could you please help me find the problem ? Guidelines
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Here's how to fix it: First issue: The filename of your Flex file is Exo.1.1.lex but your makefile references Exo.1.1.flex. Make sure these match. Here's the corrected makefile line: If that still doesn't work, you can try using the full path to the library: $(NOM).exe : lex.yy.c Another alternative is to add the homebrew lib directory to the dynamic library path in your .zshrc: export DYLD_LIBRARY_PATH="/opt/homebrew/opt/flex/lib:$DYLD_LIBRARY_PATH" |
Beta Was this translation helpful? Give feedback.
-
|
I actually find out that on Mac if you already have the "Command line tools", you don't need to install flex with Homebrew because it's already provided. With the command : You can get a list of all the tools provided. |
Beta Was this translation helpful? Give feedback.
Here's how to fix it:
First issue: The filename of your Flex file is Exo.1.1.lex but your makefile references Exo.1.1.flex. Make sure these match.
Main issue: Replace -lfl with -ll in the makefile. On macOS, the Flex library is named libl rather than libfl.
Here's the corrected makefile line:
$(NOM).exe : lex.yy.c
cc lex.yy.c -ll -o $(NOM).exe
If that still doesn't work, you can try using the full path to the library:
$(NOM).exe : lex.yy.c
cc lex.yy.c -L/opt/homebrew/opt/flex/lib -ll -o $(NOM).exe
Another alternative is to add the homebrew lib directory to the dynamic library path in your .zshrc:
export DYLD_LIBRARY_PATH="/opt/homebrew/opt/flex/lib:$DYLD_LIBRARY_PATH"
After making these c…