【问题标题】:What does " cannot open output file a.exe: Permission denied. collect2: error: ld returned 1 exit status" mean?\"cannot open output file a.exe: Permission denied.collect2: error: ld returned 1 exit status\" 是什么意思?
【发布时间】:2022-11-21 23:30:48
【问题描述】:
#include <stdio.h>
int main()
{
    int i, fact = 1, n;
    printf("Please enter a number: ");
    scanf("%d", &n);
    for(i = 1; i <= n; i++) {
        fact = fact * i;
        
    }
    printf("%d\n", fact);
    return 0;
   
}

运行一次没问题,下次运行就出现这个问题

PS D:\Programming\c programming\11a factoril> gcc 1a-facorial.c
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot open output file a.exe: Permission 
denied
collect2.exe: error: ld returned 1 exit status

请回答这个问题

【问题讨论】:

  • a.exe 似乎在后台运行。你必须先杀死它,然后再执行它。
  • @RohanBari 我怎么能杀了它......?
  • 转到任务管理器,找到进程,然后结束任务它。
  • 你如何启动程序?你给它什么输入?你得到了正确的结果打印吗?
  • @SupportUkraine 第一次打印正确。但下次出现此问题时...

标签: c factorial


【解决方案1】:

这意味着文件 a.exe 存在并且它受到保护,因为它的访问权限(或其目录的访问权限)不好(无写)或文件被锁定(可能是因为它已经被使用 - 系统阻止其覆盖,因为它正在运行或类似的东西)。

您可以尝试通过强制执行其名称来生成备用可执行文件:gcc -o executable_name source_file.c 并查看问题是否相同。如果没有问题,则出现上述情况之一,您将需要更正它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    • 2019-10-02
    • 2021-12-09
    • 2023-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多