I am an Chinese programmer, and I found that the current MinGW-w64 versions (11.2, 12.2, 13.2, released by niXman or winlibs) have two problems with directories which contain Chinese characters.
Normally, MinGW-w64 is installed in directory "C:\MinGW64". If my program "hello.cpp" saved in directory "C:\myprogs", then following compiling command will success:
C:\MinGW64\bin\g++.exe "C:\myprogs\hello.cpp" -o "C:\myprogs\hello.exe" -Wall -Wextra -pipe -I"C:\MinGW64\include" -I"C:\MinGW64\x86_64-w64-mingw32\include" -I"C:\MinGW64\lib\gcc\x86_64-w64-mingw32\13.2.0\include" -I"C:\MinGW64\lib\gcc\x86_64-w64-mingw32\13.2.0\include\c++" -L"C:\MinGW64\lib" -L"C:\MinGW64\x86_64-w64-mingw32\lib" -static-libstdc++ -static-libgcc
Problem 1: if the path of my programs contains Chinese characters, then compilation will fail.
For example, MinGW-w64 is installed in normal directory "C:\MinGW64", my program "hello.cpp" saved in directory "C:\我的程序",I typed the following compiling command::
C:\MinGW64\bin\g++.exe "C:\我的程序\hello.cpp" -o "C:\我的程序\hello.exe" -Wall -Wextra -pipe -I"C:\MinGW64\include" -I"C:\MinGW64\x86_64-w64-mingw32\include" -I"C:\MinGW64\lib\gcc\x86_64-w64-mingw32\13.2.0\include" -I"C:\MinGW64\lib\gcc\x86_64-w64-mingw32\13.2.0\include\c++" -L"C:\MinGW64\lib" -L"C:\MinGW64\x86_64-w64-mingw32\lib" -static-libstdc++ -static-libgcc
The compilation command will give message:
cc1plus.exe: fatal error: C:\鎕ello.cpp: No such file or directory
compilation terminated.
Apparently, path "C:\我的程序\hello.cpp" is not correctly processed, it was processed as "C:\鎕ello.cpp".
If I rename the program file "hello.cpp" to "测试hello.cpp", and typed the following compiling command:
C:\MinGW64\bin\g++.exe "C:\我的程序\测试hello.cpp" -o "C:\我的程序\测试hello.exe" -Wall -Wextra -pipe -I"C:\MinGW64\include" -I"C:\MinGW64\x86_64-w64-mingw32\include" -I"C:\MinGW64\lib\gcc\x86_64-w64-mingw32\13.2.0\include" -I"C:\MinGW64\lib\gcc\x86_64-w64-mingw32\13.2.0\include\c++" -L"C:\MinGW64\lib" -L"C:\MinGW64\x86_64-w64-mingw32\lib" -static-libstdc++ -static-libgcc
The compilation command will give message:
C:\骀礶llo.cpp: In function 'int main()':
C:\骀礶llo.cpp:7:36: error: expected ';' before 'return'
7 | cout << "Hello, World!" << endl
| ^
| ;
8 |
9 | return 0;
Apparently, path "C:\我的程序\测试hello.cpp" is not correctly processed, it was processed as "C:\骀礶llo.cpp".
Problem 2: If the installation directory of MinGW-w64 contains Chinese Characters, then compilation will fail.
For example, MinGW-w64 is installed in directory "C:\编译器MinGW64" which contains Chinese characters, one tried to compile program "C:\myprogs\hello.cpp" with the following command:
C:\编译器MinGW64\bin\g++.exe "C:\myprogs\hello.cpp" -o "C:\编译器hello.exe" -Wall -Wextra -pipe -I"C:\编译器MinGW64\include" -I"C:\编译器MinGW64\x86_64-w64-mingw32\include" -I"C:\编译器MinGW64\lib\gcc\x86_64-w64-mingw32\13.2.0\include" -I"C:\编译器MinGW64\lib\gcc\x86_64-w64-mingw32\13.2.0\include\c++" -L"C:\编译器MinGW64\lib" -L"C:\编译器MinGW64\x86_64-w64-mingw32\lib" -static-libstdc++ -static-libgcc
The compilation will fail, and the output message is:
C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o: No space left on device
C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/crtbegin.o: No space left on device
C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lstdc++: No space left on device
C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc: No space left on device
C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh: No space left on device
C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc: No space left on device
C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh: No space left on device
C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/crtend.o: No space left on device
collect2.exe: error: ld returned 1 exit status
It seems that the Chinese characters "编译器" are ignored in some internal stage.
Please check the two problems. Thanks.
BTW, MinGW-w64 8.1.0 does not have such problems.