This example shows how to compile a simple C++ program into a standalone Windows executable (32-bit) with a custom icon.
I used MinGW version 3.15.1 with GCC 3.4.5.
- Start by creating a test.cpp example file
#include
using namespace std;
int main () {
cout << "Hello World!";
return 0;
}
- Create a resource file (say appicon.rc) with a line defining the location of your .ico file
AppIcon ICON "MyApp.ico"
- Compile the icon into a resource object with a command like
C:\MinGW\bin\windres.exe appicon.rc appicon.opc
- Compile your executable with the resource object included with a command like
"C:\MinGW\bin\g++.exe" appicon.opc test.cpp
|