使用 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");
}
谢谢!
更新:
- 已检查任务管理器,但 .exe 未 运行在后台运行。
- 我有文件夹的写入权限
- 我的防病毒软件似乎不是问题所在
- 我可以编辑和删除 file.exe "by hand"。我使用命令行将其重命名为 file1.exe,但是当我尝试将其重命名回 file.exe 时,我得到了一个 "access denied"。即使我 运行 以管理员身份使用命令行。
- file.exe 只是问这个问题的通用名称,而不是给出
我的项目名称
看这个问题: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
确实,我的文件位于根驱动器中是问题所在。抱歉,我没有为提供帮助的人提供足够的信息。但非常感谢您的帮助!
我一直在尝试在 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");
}
谢谢!
更新:
- 已检查任务管理器,但 .exe 未 运行在后台运行。
- 我有文件夹的写入权限
- 我的防病毒软件似乎不是问题所在
- 我可以编辑和删除 file.exe "by hand"。我使用命令行将其重命名为 file1.exe,但是当我尝试将其重命名回 file.exe 时,我得到了一个 "access denied"。即使我 运行 以管理员身份使用命令行。
- file.exe 只是问这个问题的通用名称,而不是给出 我的项目名称
看这个问题: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
确实,我的文件位于根驱动器中是问题所在。抱歉,我没有为提供帮助的人提供足够的信息。但非常感谢您的帮助!