Makefile笔记01之error:"No rule to make target 'count_words', needed by '-lfl'. Stop."

来源:互联网 发布:windows源代码谁写的 编辑:程序博客网 时间:2024/05/19 14:51

最近刚开始学Makefile,遇到很多问题。

目前问题正一个个解开,和预想的一样:问题简单,知识没想到!

比如我遇到的第一个问题:

执行如下Makefile文件:

count_words: count_words.o lexer.o -lfl
gcc count_words.o lexer.o -lfl -o count_words

count_words.o: count_words.c
gcc -c count_words.c

lexer.o: lexer.c
gcc -c lexer.c

lexer.c: lexer.l
flex -t lexer.l > lexer.c

make后出现:error:"No rule to make target 'count_words', needed by '-lfl'.  Stop."

原因:在Makefile文件中的依赖存在-lfl 执行make时会自动搜寻libfl.a库文件(由flex和bison之类的工具产生)

解决方法:安装flex和bison工具

sudo apt-get install flex 

sudo apt-get installbison

阅读全文
0 0
原创粉丝点击