Windows上的gcc:生成的“ a.exe”文件消失了

查普曼

我正在使用GCC版本4.7.1,但我也在GCC 4.8上尝试过此操作。这是我要编译的代码:

#include <stdio.h>

void print(int amount) {
    int i;
    for (i = 0; i < 5; i++) {
        printf("%d", i);
    }
}

int main(int argc, char** argv) {
    print(5);
    return 0;
}

看起来应该能用,当我编译时...

gcc main.c

需要一段时间才能编译,产生一个a.exe文件,该a.exe文件消失。它不会给我任何代码错误。

这是一份证明,因为有些人误解了这一点: 证明

基思·汤普森

(由于ahoffer删除的答案不太正确,因此我将根据评论中的信息发布该答案。)

On Windows, gcc generates an executable named a.exe by default. (On UNIX-like systems, the default name, for historical reasons, is a.out.) Normally you'd specify a name using the -o option.

Apparently the generated a.exe file generates a false positive match in your antivirus software, so the file is automatically deleted shortly after it's created. I see you've already contacted the developers of Avast about this false positive.

Note that antivirus programs typically check the contents of a file, not its name, so generating the file with a name other than a.exe won't help. Making some changes to the program might change the contents of the executable enough to avoid the problem, though.

您可以尝试编译一个简单的“ hello,world”程序,看看是否发生了同样的事情。

感谢Chrono Kitsune在评论中链接到有关Mingw用户的讨论

这与您的问题无关,但是您应该'\n'在程序输出的末尾打印换行符()。在您的Windows环境中,这可能无关紧要,但通常,程序的标准输出(几乎)在最后一行的末尾始终具有换行符。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在Apache上运行.exe文件?

为什么Windows EXE文件不能在Linux上运行?

可以在windows上运行用linux制作的exe文件吗

Anaconda提示,exe文件在Windows上保存在哪里?

Windows 10 中任何 exe 文件上的错误图像错误

在Windows上的Python3中获取.exe文件的输出

如何在 Windows 上生成 .pfx 和 .cer 文件

如何在Windows上链接动态生成的cmake文件?

在 Windows 上生成 kerberos 密钥表文件需要什么?

文件菜单在Mac上的android-studio上消失了

Windows10 ld.exe 上的 GCC、GTK:找不到 -ldwmapi

文件(来自packagekit包)在Fedora 28 Workstation上消失了

如何在Linux系统上删除消失的文件?

本地分支上的“Git pull”然后每个文件都消失了

在网站文件上消失了{%csrf_token%}

在USB驱动器上,文件被成功写入后会消失

小文件夹图标在Windows 8.1中消失了

Pyinstaller生成的EXE文件不起作用

如何从ProtoGen.exe生成.vb文件

gcc编译器未在Windows for C中通过cmd创建.exe文件

使用 CodeBlocks + GCC 构建的可执行文件可以在任何 Windows 上运行吗?

如何在 iOS 上打开 .exe 文件

无法在Azure Webapp上运行EXE文件

如何在Docker上运行.exe文件?

无法在Wine上运行exe文件?

在全屏模式游戏上运行exe文件

我可以在Mac上生成可在Windows上使用的python可执行文件吗?

在Mac上为Windows .exe生成可执行应用程序

在Windows上生成和分离“ pwsh.exe”子进程不起作用