I'm trying to use flex and bison to create a simple scripting language. Right now, I'm just trying to get a calculator working.
I can't get it to compile, though. When I run this makefile:
OBJECTS = hug.tab.o hug.yy.o
PROGRAM = hug.exe
CPP = g++
LEX = flex
YACC = bison
.PHONY: all clean
all: $(OBJECTS)
$(CPP) $^ -o $(PROGRAM)
clean:
$(RM) *.o *.output *.tab.* *.yy.* $(PROGRAM)
%.tab.o: %.tab.cpp
$(CPP) -c -o $@ $<
%.tab.cpp: %.ypp
$(YACC) -vd $<
%.yy.o: %.yy.c
$(CPP) -c -o $@ $<
%.yy.c: %.l
$(LEX) -o $@ $<
%.o: %.cpp
$(CPP) -c -o $@ $<
on my .l and .ypp files, I get this error:
undefined reference to `yylex()'
And if I make the command for all
like this:
$(CPP) $^ -o $(PROGRAM) -lfl
it says it couldn't find -lfl
. And if I make it like this:
$(CPP) $^ -o -lfl $(PROGRAM)
it goes back to the undefined reference
error.
Sorry I'm kind of clueless about this.
EDIT: I have flex installed. I tried changing it from -lfl to C:/GnuWin32/lib/libfl.a (I'm trying to use Windows because Linux has odd problems on my computers and I don't have a Mac yet), but it still has the same error.