简体   繁体   English

Windows 7 x64 中的 MinGW GCC 不创建可执行文件

[英]MinGW GCC in Windows 7 x64 does not create an executable

I'm having a similar, or possibly the same issue as a few others I have seen, but I am not sure.我遇到了与我见过的其他一些人类似或可能相同的问题,但我不确定。 I am using mingw's copy of gcc directly from the windows command prompt on files in my personal directory, and I have edited the PATH to include C:\\MinGW\\bin我在个人目录中的文件上直接从 windows 命令提示符使用 mingw 的 gcc 副本,并且我编辑了 PATH 以包含 C:\\MinGW\\bin

The following:下列:

gcc -o print print.c

Grants me no output file, or so I thought.不给我输出文件,或者我是这么想的。 I opened up a file browser and sat there while gcc ran, and saw the file appear, and shortly after gcc finished, disappear.我打开了一个文件浏览器,在 gcc 运行时坐在那里,看到文件出现,并在 gcc 完成后不久消失。 I receive no error.我没有收到任何错误。

Just running刚跑

gcc print.c

yields nothing as well as什么也不产生

mingw32-gcc print.c

Here is my PATH (Cleaned up to fit my screen better):这是我的路径(经过清理以更好地适应我的屏幕):

C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;
C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files\Broadcom\Broadcom802.11;C:\Program Files\Broadcom\Broadcom 802.11\Driver;
C:\Program Files (x86)\QuickTime\QTSystem\;C:\MinGW\bin

This happens with multiple source files, but here is the source of the one I am working on in case you think that might be the issue:多个源文件会发生这种情况,但这是我正在处理的源文件,以防您认为这可能是问题所在:

#include <stdio.h>
int main(void) {
    for (;;) {
        int i;
        i = 0;
        int num;

        printf("Please enter a number:\n");
        scanf("%d", &num);
        printf("\n");

        if (num <= 0) {
            return 0;
        }

        while (i <= num) {
            printf("%d\n", i);
            i++;
        }
    }
}

Yes, I know it is really simple, I am just getting started on learning C.是的,我知道这真的很简单,我才刚刚开始学习 C。

Any ideas?有任何想法吗?

I'm downloading Code::Blocks right now, and will update if I find out that it works correctly there.我现在正在下载 Code::Blocks,如果我发现它在那里正常工作,我会更新。

Edit: Requested output ahead编辑:提前请求输出

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=m
ingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto
--enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++
,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-l
ibstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gm
p-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --
with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-
libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/
mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
Thread model: win32
gcc version 4.8.1 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro'
 c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/cc1.exe -quiet -v -iprefix c:\mingw\b
in\../lib/gcc/mingw32/4.8.1/ print.c -quiet -dumpbase print.c -mtune=generic -ma
rch=pentiumpro -auxbase print -version -o C:\Users\kyle\AppData\Local\Temp\ccBlz
Ym1.s
GNU C (GCC) version 4.8.1 (mingw32)
        compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/inclu
de"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/../..
/../../include"
ignoring duplicate directory "/mingw/include"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/inclu
de-fixed"
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.8.1/../..
/../../mingw32/include"
ignoring duplicate directory "/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include
 c:\mingw\bin\../lib/gcc/mingw32/4.8.1/../../../../include
 c:\mingw\bin\../lib/gcc/mingw32/4.8.1/include-fixed
 c:\mingw\bin\../lib/gcc/mingw32/4.8.1/../../../../mingw32/include
End of search list.
GNU C (GCC) version 4.8.1 (mingw32)
        compiled by GNU C version 4.8.1, GMP version 5.1.2, MPFR version 3.1.2,
MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 767202a405449496e68a54c4eee91a28
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro'
 c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/as.exe -v -o C:\U
sers\kyle\AppData\Local\Temp\cc3cEZAy.o C:\Users\kyle\AppData\Local\Temp\ccBlzYm
1.s
GNU assembler version 2.24 (mingw32) using BFD version (GNU Binutils) 2.24
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/;c:/mingw/bin/../libexec
/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.8.1/;c:/mingw/bin/../lib/gcc/;c:/
mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/lib/;c:/mingw/bin/../lib/
gcc/mingw32/4.8.1/../../../
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro'
 c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/collect2.exe -Bdynamic c:/mingw/bin/.
./lib/gcc/mingw32/4.8.1/../../../../mingw32/lib/crt2.o c:/mingw/bin/../lib/gcc/m
ingw32/4.8.1/crtbegin.o -Lc:/mingw/bin/../lib/gcc/mingw32/4.8.1 -Lc:/mingw/bin/.
./lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/lib -Lc:/m
ingw/bin/../lib/gcc/mingw32/4.8.1/../../.. C:\Users\kyle\AppData\Local\Temp\cc3c
EZAy.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell
32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt c:
/mingw/bin/../lib/gcc/mingw32/4.8.1/crtend.o

Edit: I get the same issue in Code::Blocks.编辑:我在 Code::Blocks 中遇到了同样的问题。

I had similar issue where no output files were created.我有类似的问题,没有创建输出文件。

The following packages were installed at the time : mingw-developer-toolkit, mingw32-gcc-g++, msys-base当时安装了以下软件包:mingw-developer-toolkit、mingw32-gcc-g++、msys-base

To resolve the problem, i installed mingw32-base为了解决这个问题,我安装了 mingw32-base

Your first command gcc -o print print.c creates an executable named print , not print.exe .您的第一个命令gcc -o print print.c创建一个名为print的可执行文件,而不是print.exe Use gcc -o print.exe print.c to get an executable that you can run easily from the command prompt.使用gcc -o print.exe print.c获取可执行文件,您可以从命令提示符轻松运行该可执行文件。

The second and third commands produces an executable named a.exe .第二个和第三个命令生成一个名为a.exe的可执行文件。 You can type a on the command prompt to run this executable.您可以在命令提示符下键入a来运行此可执行文件。

I hit the same problem but with MinGW-64.我遇到了同样的问题,但使用 MinGW-64。 The solution was to start mingw64.exe shell and to run compilation process there, but not in msys2.exe shell.解决方案是启动 mingw64.exe shell 并在那里运行编译过程,但不在 msys2.exe shell 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM