Setting up MinGW for C/C++ Win32
Posted: Thu Aug 01, 2013 11:45 am
It is assumed that installed the MinGW compiler as described here.
If you start Zeus, select the Templates panel from the navigator on the left, select the C/C++ Document Type
from the list at the top and double click on the Application (Windows) option.
That will create a simple Win32 application. Save that code to the c:\temp\winapp.cpp file.
If you compile this using the Compiler, Compile menu you'll most likely get this error message:
These errors indicate in linking the winapp.exe the linker could not resolve the missing Win32 functions listed.
These are stock standard Win32 functions and they live in the gdi32 and user32 windows libraries.
So what is needed is add these libraries to the command line using the -l option so that the linker can resolve these functions.
To do this just change the command line to be as follows:
Now, re-compiling will result in no errors and the winapp.exe file is created in the temp folder.
Running this executable will display the Hello Windows Win32 GUI application shown below.
Cheers Jussi
If you start Zeus, select the Templates panel from the navigator on the left, select the C/C++ Document Type
from the list at the top and double click on the Application (Windows) option.
That will create a simple Win32 application. Save that code to the c:\temp\winapp.cpp file.
If you compile this using the Compiler, Compile menu you'll most likely get this error message:
Code: Select all
winapp.cpp:(.text+0x75): undefined reference to `_imp__GetStockObject@4'
winapp.cpp:(.text+0x202): undefined reference to `_imp__SetBkMode@8'
winapp.cpp:(.text+0x249): undefined reference to `_imp__SetTextColor@8'
winapp.cpp:(.text+0x281): undefined reference to `_imp__TextOutA@20'
These are stock standard Win32 functions and they live in the gdi32 and user32 windows libraries.
So what is needed is add these libraries to the command line using the -l option so that the linker can resolve these functions.
To do this just change the command line to be as follows:
Code: Select all
g++.exe -x c++ -Wall -std=c++11 "$fn" -lgdi32 -luser32 -o "$fdd$fb.exe"
Running this executable will display the Hello Windows Win32 GUI application shown below.
Cheers Jussi