![]() |
|
adding a windows icon to the exe |
Mark Oates
Member #1,146
March 2001
![]() |
I've read the wiki article and searched on the forums but haven't been able to get an icon into my windows exe. My understanding is that I create an icon. (.ico file), then compile that icon into a resource file using windres.exe. My result is only slightly larger in size than my icon file, so I assume that part worked correctly. Then I just link that resource into my exe when I compile the program. This appears to be the part where it doesn't work correctly. I'm using Code::Blocks and under Project>Build Options...>Linker Settings tab>Other linker options, I append the filename of my resource file, "icon_rc.res". so, using openlayer, my "other linker options" looks like: I tried including the "icon_rc.res" file in the directory with my programs files, and the mingw/bin directory, neither worked. What am I missing? Do I need to WinMain()? On a side note, is it possible to get an icon working for multi-platform? -- |
Audric
Member #907
January 2001
|
Winmain is not needed. Make sure your resource file starts with "1 ICON ", because the linker will only search for a resource called "ICON". Are you sure you're not linking the resource file (text) instead of the generated .o file ? |
Mark Oates
Member #1,146
March 2001
![]() |
the resource file "icon.rc" is: #include <windows.h> allegro_icon ICON fullscore_icon01.ico
so I run at the command line "windres -O coff -o icon.res -i icon.rc" inside the directory with the icon.rc and fullscore_icon01.ico in that same directory. and the compiled result is "icon.res" which I rename to "icon_rc.res" and put into the C:\Program Files\CodeBlocks\MinGW\lib then I try an compile the program with that above "other linker options" list and... nothing. -- |
Audric
Member #907
January 2001
|
Well, no idea then... I'm more familiar with the variant I use for a program that doesn't use Allegro (SDL instead). It's with Mingw compiler tools and GNU Make, in Makefile : # Resources (icon) WINDRES = windres.exe # Link the icons to the program under windows $(OBJDIR)/winres.o : gfx2.ico echo "1 ICON \"gfx2.ico\"" | $(WINDRES) -o $(OBJDIR)/winres.o And $(OBJDIR)/winres.o is one of the input files for the linker. Seems very similar, only big difference is I use a pipe to feed the "resource script", and my resulting object has file extension .o instead of .res. I don't know if the file extension matters... And it's surprising that you get no error message, just a standard executable icon in the explorer. |
DanielH
Member #934
January 2001
![]() |
change it to "allegro_icon" with the quotes and try it again |
Mark Oates
Member #1,146
March 2001
![]() |
I tried "allegro_icon" with the quotes, and that didn't seem to work. I've attached the resource file and the icon, would somebody check that these are working? -- |
verthex
Member #11,340
September 2009
![]() |
Audric
Member #907
January 2001
|
According to one man page of windres (link) the ".res" and ".o" are normally different file extensions for different formats. Note that the output of windres is a normal generated object, specific to this project, just like foo.o you compile from foo.c ... you don't have to put it in lib/ folder. edit So the problem must be in how you tell Code::blocks to link it. I've seen that that Dev-cpp also names the output of WINDRES, in COFF format, as "something.res"; so this file extension is not a problem for the linker. |
ImLeftFooted
Member #3,935
October 2003
![]() |
You got the right approach but you just have press the keys harder while you do it. |
Mark Oates
Member #1,146
March 2001
![]() |
Audric said: So the problem must be in how you tell Code::blocks to link it. Ah-HA! That's it! All I had to do was add the .rec file to my Code::Blocks project. Code::Blocks automatically put it in a "Resources" folder and then links it automatically. Go figure {"name":"599507","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/8\/9831d8abcf180add1b63105451c0a1b6.png","w":258,"h":547,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/8\/9831d8abcf180add1b63105451c0a1b6"} Thanks everybody! -- |
|