How can I add an icon to my MinGW compiled program for Windows?

  • Thread starter Thread starter Coin
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around how to add an icon to a Windows executable file compiled with MinGW, particularly from a macOS environment. Participants explore methods to associate or embed an icon in the .exe file without direct access to Windows functionalities.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant describes their setup of compiling Windows executables on macOS using MinGW and seeks guidance on embedding an icon in the .exe file.
  • Another participant suggests using Windows API functions like LoadIcon, referencing a programming book for further reading.
  • A participant clarifies that they want a static icon for the application, not a runtime change, and expresses confusion about how to achieve this without Windows access.
  • One participant shares their experience using Code::Blocks and MinGW on Windows, mentioning that including an icon file as a resource is straightforward.
  • A later reply points to a specific tutorial as a solution for command line tools, indicating that they successfully implemented it.
  • Another participant references an alternative tutorial that they found easy to follow for adding icons.

Areas of Agreement / Disagreement

Participants present various methods and resources for adding an icon, but there is no consensus on a single approach. Multiple suggestions and tutorials are provided, reflecting differing experiences and preferences.

Contextual Notes

Some participants mention limitations due to not being on a Windows system, which may affect their ability to test or implement certain solutions directly. There is also a reliance on external resources and tutorials, which may vary in clarity and applicability.

Coin
Messages
564
Reaction score
1
Okay, here's one.

- I'm developing a program for macintosh+windows.
- But, I myself am on a macintosh.
- So, I installed MinGW on my mac. Now, I can compile Windows .exes sitting here on my macintosh. (This part already works.)
- But I can't figure out: How do I give my program an icon?

I have here a .ico I made, but I don't know how to associate it with or embed it into my Windows .exe. I don't really know how Windows icons work. Is there a way to do this using mingw or any open source tool I can run on my mac? (I.E. what I'm trying to do somehow prep the exe is so that when I zip it up and send it over to a windows machine, the windows user will see the icon immediately.)
 
Technology news on Phys.org
It is a GUI app or Console app?
You should try some windows API function such as LoadIcon. You should read books such as <<windows programming>> by Charles Petzold.
 
It is a normal type gui app.

I'm not sure what you mean about the API? I don't mean I want to change the icon at runtime, I mean like I want some file to be the program's icon even before it launches and I can't do the normal thing of right click->properties because I'm not actually on windows myself.
 
Oh, I'm using code::blocks and Mingw under windows, so, with application wizard, it is easy to generate a gui application.
You can use include an icon file as it's resource file.
That all I know.
 
OK. Thanks for the help.

It turns out that the correct answer if you're limited to the command line tools is to http://www.cyrocom.co.uk/tutorials/cpp/icon.html . I got it working using this.
 
Last edited by a moderator:
Hi. Actually the http://blog.stranadurakov.com/2009/04/27/icon-and-version-information-resource-file/" is pretty easy.
 
Last edited by a moderator:

Similar threads

  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 29 ·
Replies
29
Views
3K
Replies
14
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
6K
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 23 ·
Replies
23
Views
8K