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

大家好,我用winlib的C编译器在win下编译成功 #24

Open
qwas982 opened this issue Aug 22, 2024 · 1 comment
Open

大家好,我用winlib的C编译器在win下编译成功 #24

qwas982 opened this issue Aug 22, 2024 · 1 comment

Comments

@qwas982
Copy link

qwas982 commented Aug 22, 2024

大家好,我用winlib的C编译器在win下编译成功,

但是需要改变makefile文件的编写.
mingw64是默认的,
makefile文件改造为如下:

# 目标可执行文件
目标 = mzcc

# 编译选项
编译选项 = -Wall -Werror -std=gnu99 -g -I.

# 对象文件
对象文件 = lexer.o codegen_x64.o parser.o verbose.o main.o

# 依赖文件
依赖文件 := $(对象文件:%.o=.%.o.d)

# 规则:编译 .c 文件为 .o 文件
%.o: %.c
	@echo "  CC     $@"  # 使用 echo 代替 printf
	$(CC) -o $@ $(编译选项) -c -MMD -MF [email protected] $<

# 规则:链接对象文件生成目标可执行文件
$(目标): $(对象文件)
	@echo "  LD     $@"  # 使用 echo 代替 printf
	$(CC) $(编译选项) -o $@ $^

# 清理生成的文件
.PHONY: clean
clean:
	$(RM) $(目标) $(对象文件) $(依赖文件)  # 确保这一行前面是制表符

# 包含依赖文件
-include $(依赖文件)

随后在wt的ps里执行make得到

PS Z:\MazuCC-master> make
"  CC     lexer.o"  # 浣跨敤 echo 浠f浛 printf
cc -o lexer.o -Wall -Werror -std=gnu99 -g -I. -c -MMD -MF .lexer.o.d lexer.c
"  CC     codegen_x64.o"  # 浣跨敤 echo 浠f浛 printf
cc -o codegen_x64.o -Wall -Werror -std=gnu99 -g -I. -c -MMD -MF .codegen_x64.o.d codegen_x64.c
"  CC     parser.o"  # 浣跨敤 echo 浠f浛 printf
cc -o parser.o -Wall -Werror -std=gnu99 -g -I. -c -MMD -MF .parser.o.d parser.c
"  CC     verbose.o"  # 浣跨敤 echo 浠f浛 printf
cc -o verbose.o -Wall -Werror -std=gnu99 -g -I. -c -MMD -MF .verbose.o.d verbose.c
"  CC     main.o"  # 浣跨敤 echo 浠f浛 printf
cc -o main.o -Wall -Werror -std=gnu99 -g -I. -c -MMD -MF .main.o.d main.c
"  LD     mzcc"  # 浣跨敤 echo 浠f浛 printf
cc -Wall -Werror -std=gnu99 -g -I. -o mzcc lexer.o codegen_x64.o parser.o verbose.o main.o

这表明项目构建成功了.

@qwas982
Copy link
Author

qwas982 commented Aug 22, 2024

用原始的makefile文件并不能成功,

我是问gpt-4o-mini-2024-07-18大模型,得到了修改后的配置文件.并成功的.
我的提示语为: 重构这个make文件, 使用中文标识符编写,并且,去掉多余的配置代码,只保留构建项目的部分.

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