Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第一次执行make -s test报错及其解决办法,mv: cannot stat '/ucl': No such file or directory #13

Open
oxygen236 opened this issue Apr 22, 2023 · 0 comments

Comments

@oxygen236
Copy link

第一次执行make -s test报错及其解决办法,mv: cannot stat '/ucl': No such file or directory

在书(C 编译器剖析,邹昌伟)的第 23 页中第一次执行make -s test时,报错内容如下:

[oxygen@****** ucc]$ make -s test
(exprchk.c,314):(output.c,70):warning:Too many arguments
(exprchk.c,314):(output.c,86):warning:Too many arguments
mv: cannot stat '/ucl': No such file or directory
make[1]: *** [Makefile:21: test] Error 1
make: *** [Makefile:25: test] Error 2

问题原因:多级 makefile 及参数传递问题,ucc/Makefile 文件中的变量 $(UCCDIR) 没有传递到 ucc/ucl/Makefile 中,导致报错。
解决办法:将 ucc/Makefile 文件的UCCDIR定义前加 export

正确的 ucc/Makefile 文件如下:

#UCCDIR = /home/iron/bin
cur_mkfile := $(abspath $(lastword $(MAKEFILE_LIST)))
export UCCDIR = $(patsubst %/, %, $(dir $(cur_mkfile)))/bin

修改后重新执行,结果如下

[oxygen@****** ucc]$ make -s test
(exprchk.c,314):(output.c,70):warning:Too many arguments
(exprchk.c,314):(output.c,86):warning:Too many arguments
(exprchk.c,314):(output.c,70):warning:Too many arguments
(exprchk.c,314):(output.c,86):warning:Too many arguments

可能对你有帮助的 makefile 相关代码:

1.打印当前Makefile的路径:

$(warning Makefile path: $(CURDIR)/$(lastword $(MAKEFILE_LIST)))

2.在控制台输出变量 $(UCCDIR)/ucl 的值

$(info $(UCCDIR)/ucl)

希望能帮助到有需要的人!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant