当我编译我的makefile时,我遇到了这个问题:
gcc parser.tab.o -o parser.tab
/usr/lib/../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
parser.tab.o: In function `yyparse':
parser.tab.c:(.text+0x2c3): undefined reference to `yylex'
parser.tab.c:(.text+0x3f5): undefined reference to `execute'
parser.tab.c:(.text+0x82b): undefined reference to `yyerror'
parser.tab.c:(.text+0x947): undefined reference to `yyerror'
collect2: ld returned 1 exit status
make: *** [parser.tab] Error 1
这是我的make文件:
CC = gcc
CFLAGS = -lreadline
PROGS = d8sh parser.tab executor lexer
all: $(PROGS)
clean:
rm -f *.o $(PROGS) *.tmp
d8sh: d8sh.o
d8sh.o: executor.h lexer.h
executor.o: command.h
lexer.o: parser.tab.h
parser.tab.o: command.h
只有d8sh.c有一个主要功能。谁能弄明白问题是什么?