使用 gcc (minGW) 构建具有相同文件名的 .exe 时出错?

Error when using gcc (minGW) to build .exe with same filename?

我一直在尝试在 minGW 中构建另一个同名的 .exe 文件,但每次我 运行 命令:gcc file.c -o file.exe 我 运行 都会遇到以下问题:

c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: 
cannot open output file main.exe: Permission denied
collect2.exe: error: ld returned 1 exit status

但是,如果我 运行 与 gcc file.c -o file2.exe 相同的命令,该命令执行得很好,我可以编译我的 C 代码。 有什么方法可以生成同名的.exe文件吗?

我的 C 代码很简单 "hello world":

#include<stdio.h>

void main(){
   printf("hello world");
}

谢谢!

更新:

看这个问题:Command prompt access is denied

我看到有帮助的评论:

Noting C:> in your question, your Windows root drive is usually write protected, you may find that simply changing directory to somewhere without that protection may also help. – Compo

确实,我的文件位于根驱动器中是问题所在。抱歉,我没有为提供帮助的人提供足够的信息。但非常感谢您的帮助!