Waitrud Weber’s blog

things and reminders for memories

windows-make: c++: Compilation in the way which is a trivia.

1.We exclude "tchar.h" but it is in all includion.

1-1.We can include "tchar.h" if we use mingw-32.exe for a compilation.

 

2.We can choose the library-i686.

*

Raw - select -
1 mingw-32.exe o -
2 tchar.h o -
3 g++ x -
4 C:\DEV\xpack-windows-build-tools-4.4.1-3\bin\make.exe 

o

x(x86_64)

-
5 x86_64(WIN64) o(Raw8) -
6 i686(WIN32) o -
7 MinGW o -
8 MinGW\bin\make.exe o -
9 strsafe.h x -
- - - -

 

The above is like the previous one, which means a way of compilation doesn't change so much.

StringCchPrintfA function (strsafe.h) - Win32 apps | Microsoft Learn

mingw32-g++ -Wall -O3 -I C:\DEV\x86_64\x86_64-w64-mingw32\include -L C:\DEV\x86_64\x86_64-w64-mingw32\lib -mwindows -lgdi32 -lws2_32 -lwsock32 -o thread_print.o -c thread_print.cpp
thread_print.cpp:5:21: fatal error: strsafe.h: No such file or directory
 #include <strsafe.h>
                     ^
compilation terminated.
Makefile:73: recipe for target 'thread_print.o' failed
make: *** [thread_print.o] Error 1
PS C:\Users\benetton\Documents\source\axex-20230816> dir C:\DEV\x86_64\x86_64-w64-mingw32\include\strsafe.h


    directory: C:\DEV\x86_64\x86_64-w64-mingw32\include


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2025/10/31     18:37          73349 strsafe.h

 

PS C:\Users\benetton\Documents\source\axex-20230816> make all
mingw32-g++ -Wall -O3 -I C:\DEV\i686\i686-w64-mingw32\include -L C:\DEV\i686\i686-w64-mingw32\lib -mwindows -lgdi32 -lws2_32 -lwsock32 -o thread_print.o -c thread_print.cpp
thread_print.cpp:5:21: fatal error: strsafe.h: No such file or directory
 #include <strsafe.h>
                     ^
compilation terminated.
Makefile:73: recipe for target 'thread_print.o' failed
make: *** [thread_print.o] Error 1
PS C:\Users\benetton\Documents\source\axex-20230816> dir C:\DEV\i686\i686-w64-mingw32\include\strsafe.h


    directory: C:\DEV\i686\i686-w64-mingw32\include


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2025/11/05     19:40          73349 strsafe.h

 

 

 

windows-make: C++: Compilation should be for 64-bit or 32-bit executable.

Compilation Error:
C:\DEV\mingw64\x86_64-w64-mingw32\include/_mingw_stdarg.h:11:2: error:
#error Only Win32 target is supported!

*
1. The compilation message keyword "#error" should be threw or not.
2. They are two only, and the one can create 64-bit executable and the other one can do 32-bit.

 

*

- compiler success or not - -
- g++ x - -
- migw32-g++ o - -
- - - - -
- - - - -

 

*

- make tool success or not - -
- mingw make x - -
- toolchain make o 2018/05/01 -
- - - - -
- - - - -

 

*File Format

- - Macro WinMain/wWinMain Ensured
- Unicode _tWinMain wWinMain Written
- SJIS - - -
- - - - -
- - - - -

 

*_tWinMain c++ - Google Search

All Overview:
In C++ Windows programming, _tWinMain is a macro that resolves to either WinMain or wWinMain depending on whether the UNICODE preprocessor symbol is defined. Its purpose is to allow developers to write code that can be compiled for both ANSI and Unicode character sets without having to modify the entry point function name.

 

*exclude tchar.h 

- compiler - - - exclude tchar.h
- mingw32-g++ o winmain_001__03.cpp(set) - o
- g++ #error winmain_001_02.cpp WinMain o
- g++  #error _03.cpp(set)/array_counter.cpp - o
- mingw32-g++ o winmain_001_02.cpp WinMain o

 

Anyway, We exclude tchar.h because linking error occurs if we choose any library excluding x86_64 and i686.

And, so, We use default Mingw library like the below:

PS C:\Users\benetton\Documents\source\axex-20251014> C:\DEV\xpack-windows-build-tools-4.4.1-3\bin\make.exe all
mingw32-g++ -Wall -O3 -I C:\DEV\MinGW\include -L C:\DEV\MinGW\lib -mwindows -lgdi32 -lws2_32 -lwsock32 -o winmain_001_02.o -c winmain_001_02.cpp
mingw32-g++ winmain_001_02.o -Wall -O3 -I C:\DEV\MinGW\include -L C:\DEV\MinGW\lib -mwindows -lgdi32 -lws2_32 -lwsock32 -o winmain_001.exe

 

 

 

windows-make: C++: We can choose 2 targets for library.

Which number is 64 or not?

Mingw-w64 - Wikipedia

... Mingw-w64 can generate 32-bit and 64-bit executables for x86 under the target names i686-w64-mingw32 and x86_64-w64-mingw32.

*Google Explanation

Solution: Ensure that the libmingw32.a library you are linking against matches the target architecture (32-bit or 64-bit) of your compilation. If you are using a 64-bit compiler (e.g., x86_64-w64-mingw32-g++), you need to use the 64-bit version of libmingw32.a. Similarly, for a 32-bit compiler (e.g., i686-w64-mingw32-g++), use the 32-bit library.

 

*Which means a target is for 32-bit and 64-bit

- - target - library - executable
- x86 i686 WIN32 mingw32\
mingw32\i686-w64-mingw32\
w64 32-bit
64-bit
- x86 x86_64 WIN64 mingw64\
mingw64\x86_64-w64-mingw32\
w64 32-bit
64-bit
- - - - - - -

 

*
x86 - Wikipedia

1978 (16-bit), 1985 (32-bit), 2003 (64-bit)

CISK

 

*i686

P6 (microarchitecture) - Wikipedia

equals i686.

discontributed CISK and RISK also.

... into sequences of buffered RISC-like micro-operations, then analyze and reorder ...

Other features first implemented in the x86 space in the P6 core include:

 

*

- - - -
- CISK- - -
- RISK - -
- buffered RISC-like Microarchitecture - Wikipedia
Micro-operation - Wikipedia
Intel Core2



- - - -
- - - -
- - - -
- - - -



- - - -
- - - -
- - - -
- - - -



- - - -
- - - -
- - - -
- - - -

 

#MinGW

 

windows-make: c++: It doesn't pick the file "tchar.h" up.

Compilation message has changed if we change the option and includion."fatal error: tchar.h: No such file or directory" is or any other. Any other is better, which doesn't pick the file "tchar.h" up even though there is it.

 

*

- - - -
- PS C:\Users\benetton\Documents\source\axex-20230816> make.exe all
g++ -Wall -O3 -I C:\DEV\MinGW\include -o wTextarea.o -c wTextarea.cpp
wTextarea.cpp:3:19: fatal error: tchar.h: No such file or directory
 #include <tchar.h>
                   ^
compilation terminated.
Makefile:65: recipe for target 'wTextarea.o' failed
make: *** [wTextarea.o] Error 1
- -
-

PS C:\Users\benetton\Documents\source\axex-20230816> dir C:\DEV\MinGW\include\tchar.h


    directory: C:\DEV\MinGW\include


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2017/12/07      5:09          13716 tchar.h

- -
- - - -


*

- - - -
-

PS C:\Users\benetton\Documents\source\axex-20230816> make.exe all
g++ -Wall -O3 -I C:\\DEV\\mingw64\\x86_64-w64-mingw32\\include -o wTextarea.o -c wTextarea.cpp
In file included from C:\DEV\mingw64\x86_64-w64-mingw32\include/stdarg.h:140:0,
                 from C:\DEV\mingw64\x86_64-w64-mingw32\include/windows.h:66,
                 from wTextarea.cpp:4:
C:\DEV\mingw64\x86_64-w64-mingw32\include/_mingw_stdarg.h:11:2: error: #error Only Win32 target is supported!
 #error Only Win32 target is supported!
  ^
In file included from wTextarea.cpp:7:0:
wEvent.h:7:3: warning: identifier 'nullptr' is a keyword in C++11 [-Wc++0x-compat]
   HWND hWnd = nullptr;
   ^
In file included from C:\DEV\mingw64\x86_64-w64-mingw32\include/_cygwin.h:14:0,
                 from C:\DEV\mingw64\x86_64-w64-mingw32\include/_mingw.h:15,
                 from C:\DEV\mingw64\x86_64-w64-mingw32\include/corecrt.h:10,
                 from C:\DEV\mingw64\x86_64-w64-mingw32\include/corecrt_stdio_config.h:10,
                 from C:\DEV\mingw64\x86_64-w64-mingw32\include/stdio.h:9,
                 from wTextarea.cpp:1:
C:\DEV\mingw64\x86_64-w64-mingw32\include/stddef.h:18:3: error: '_CRTIMP' does not name a type
   _CRTIMP extern int *__cdecl _errno(void);
   ^

- -
- - - -
- - - -



*

- - - -
- - - -
- - - -
- - - -