我有一个类似的问题,可能与其他一些人看到的问题相同,但我不确定。我直接从Windows命令提示符中使用mingw的gcc副本处理我的个人目录中的文件,并编辑了PATH以包含C:\MinGW\bin。
以下内容:
gcc -o print print.c
我没有得到任何输出文件,或者我以为是这样。 我打开了一个文件浏览器,在gcc运行时坐在那里,看到文件出现,gcc很快完成后,文件就消失了。我没有收到任何错误提示。
只是运行
gcc print.c
没有产生任何结果
mingw32-gcc print.c
这是我的路径(已经清理过,以更好地适应我的屏幕):
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
这种情况发生在多个源文件中,但以下是我正在处理的源文件的来源,以防您认为这可能是问题所在:
#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++;
}
}
}
是的,我知道这非常简单,我刚开始学习C语言。
有什么想法吗?
我正在下载Code::Blocks,如果我发现它可以正常工作,我会进行更新。
编辑: 请求提前输出
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
编辑: 我在Code::Blocks中遇到了同样的问题。
gcc -v print.c
并将输出复制到您的问题中。 - Ross Ridge