Closed JohnnyLee91 closed 1 year ago
C:/MinGW-w64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o This path doesn't look like it's from w64devkit to me, is it possible you have multiple compiler installations conflicting on windows 7?
The verbose output listing matches w64devkit, so despite the root being called "MinGW-w64" that looks like w64devkit. Perhaps the filesystem is corrupt? Looks like it got a seek error on crt2.o. Try checking, say, the md5sum on that file to see that it matches a working install. I suspect there will be an error computing the sum.
On second thought, I see what you mean now, @Peter0x44. It's the right linker executable, but it's probably picking up the wrong CRT bits, from another installation.
@Peter0x44 @skeeto Sorry~ I forgot to mention that I have changed the root directory name from "w64devkit" to "MinGW-w64". And I also have tried with the original root directory name, but the issue still exists.
@Peter0x44 @skeeto Sorry~ I forgot to mention that I have changed the root directory name from "w64devkit" to "MinGW-w64". And I also have tried with the original root directory name, but the issue still exists.
Windows 7 x64 SP1, all updates, no other C/C++ installs. Didn't have any problems with gcc, at least at basic "Hello world!"
#include <stdio.h>
int main(int argc, char* argv[])
{
printf("Hello World!\r\n");
return 0;
}
Was downloaded:
w64devkit-fortran-1.19.0.zip
Was unpacked to:
C:\ProgramData
In console (cmd.exe):
C:\WORK>gcc
'gcc' is not recognized as an internal or external command,
operable program or batch file.
C:\WORK>set path=%path%;%ALLUSERSPROFILE%\w64devkit\bin
C:\WORK>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/ProgramData/w64devkit/bin/../libexec/gcc/x86_64-w64-mingw32/13.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: /gcc-13.1.0/configure --prefix=/w64devkit --with-sysroot=/w64devkit/x86_64-w64-mingw32 --with
-native-system-header-dir=/include --target=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-static --dis
able-shared --with-pic --with-gmp-include=/deps/include --with-gmp-lib=/deps/lib --with-mpc-include=/deps/incl
ude --with-mpc-lib=/deps/lib --with-mpfr-include=/deps/include --with-mpfr-lib=/deps/lib --enable-languages=c,
c++,fortran --enable-libgomp --enable-threads=posix --enable-version-specific-runtime-libs --disable-dependenc
y-tracking --disable-multilib --disable-nls --disable-win32-registry --enable-mingw-wildcard CFLAGS_FOR_TARGET
=-Os CXXFLAGS_FOR_TARGET=-Os LDFLAGS_FOR_TARGET=-s CFLAGS=-Os CXXFLAGS=-Os LDFLAGS=-s
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.1.0 (GCC)
C:\WORK>gcc test.c -o test.exe
C:\WORK>test.exe
Hello World!
@skeeto @Peter0x44 Hey guys, thanks for your tips. I have fixed this issue which is not a bug of w64devkit itself. That's because I got the cygwin and w64devkit (renamed as "MinGW-64") on my system in a mess:
C:\Users\Johnny>where gcc C:\MinGW-w64\bin\gcc.exe
C:\Users\Johnny>where gcc2 C:\Cygwin64\bin\gcc2.exe
C:\Users\Johnny> C:\Users\Johnny>where ld C:\Cygwin64\bin\ld.exe C:\MinGW-w64\bin\ld.exe
With such a mess in the PATH environment variable, when I run gcc, the ld.exe in cygiwn environment wil be called by mistake... Sorry for wasting your precious time and I will close this issue.
I got a bad file descriptor error when using gcc in Windows 7 (64-bit) commmad prompt. But if I launch w64devkit.exe and execute gcc command whihin it, everything goes well.
gcc in Windows command prompt:
gcc in w64devkit console:
I have tried run gcc in the command prompt of Windows 11, it also works well.
Here is my Windows 7 system info: