海湾合作委员会在Windows上:生成" a.exe的"文件消失 [英] gcc on Windows: generated "a.exe" file vanishes
问题描述
我使用GCC 4.7.1版本,但我也试过这对GCC 4.8。这里是code,我试图编译:
I'm using GCC version 4.7.1, but I've also tried this on GCC 4.8. Here is the code I'm trying to compile:
#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;
}
它看起来像它应该工作,当我编译...
It looks like it should work, and when I compile with...
gcc main.c
这需要一段时间来编译,生成一个 A.EXE
文件和在 A.EXE
文件消失。它没有给我任何错误与我的code。
It takes a while to compile, produces an a.exe
file and the the a.exe
file disappears. It isn't giving me any errors with my code.
下面是证明的GIF,因为有些人是misinter preting这样的:
Here's a gif of proof, as some people are misinterpreting this:
推荐答案
(自ahoffer的删除答案是不是很正确的,我会发布此基础上,在评论信息。)
(Since ahoffer's deleted answer isn't quite correct, I'll post this, based on information in the comments.)
在Windows上,GCC默认生成一个名为 A.EXE
的可执行文件。 (在类UNIX系统中,默认名称,由于历史原因,是的a.out
。)通常你会使用指定名称的 - 0
选项。
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.
显然生成的 A.EXE
文件中的防病毒软件生成假阳性匹配,所以它的创建后不久,该文件被自动删除。我看你已经停住开发商这个假阳性href=\"http://www.avast.com/contact-form.php\" rel=\"nofollow\">。
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.
请注意防病毒程序通常检查文件,而不是它的名称的内容的,所以生成的文件比 A.EXE
也无济于事。做一些修改程序可能会改变足够可执行的内容,以避免这个问题,虽然。
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.
您可以尝试编写一个简单的你好,世界节目,看是否发生相同的事情。
You might try compiling a simple "hello, world" program to see if the same thing happens.
由于计时狐狸链接到此相关的称为Mingw用户讨论在注释中。
Thanks to Chrono Kitsune for linking to this relevant Mingw-users discussion in a comment.
这是不相关的问题,但你应该在你的程序的输出的末尾打印一个换行符(的'\\ n'
)。它可能没有多大关系在Windows环境中,但一般一个程序的标准输出应该(几乎)的总是的有文件的最后一行的末尾换行符。
This is not relevant to your problem, but you should print a newline ('\n'
) at the end of your program's output. It probably doesn't matter much in your Windows environment, but in general a program's standard output should (almost) always have a newline character at the end of its last line.
这篇关于海湾合作委员会在Windows上:生成&QUOT; a.exe的&QUOT;文件消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!