Trying to add icon

Oct 22, 2013 at 4:51pm
I am trying to add a icon to a C++ project in eclipse to the exe itself.
Last edited on Oct 22, 2013 at 11:45pm
Oct 22, 2013 at 5:47pm
You have to create a resource file then add it to your project. Not sure if eclipse can do it easy but I know code::blocks and visual studios can.

The resource would be something like this

1
2
//resource.rc
some_icon ICON "my_icon.ico"


I would also suggest using guards

1
2
3
4
5
6
7
//resource.rc
#ifndef RESOURCE_RC
#define RESOURCE_RC

someicon ICON "myIcon.ico"

#endif 

Oct 22, 2013 at 11:45pm
ya i know im trying to find out how to add it in eclipse.
Oct 23, 2013 at 12:04am
It looks like you need to use winres.


How to handle Resource-Script-Files '*.rc' with CDT?
Currently handling of windres.exe with CDT is not possible. You can not add the .rc file to the project to be compiled and linked with automatically. This is already raised as a bug in bugzilla.

One way is to create a Pre-Build Step. Under menue
Project | Properties | C/C++-Build | Settings | Build Steps | Pre-Build Steps
fill in the command-line:
windres --use-temp-file -i..\MyProject.rc -o..\MyProject_rc\MyProject_rc.o
Make the object known to the linker. Under menue
Project | Properties | C/C++-Build | Settings
Tool Settings | MinGW C++ Linker | Miscellaneous | Other Objects
click the icon 'Add', fill in the line:
"C:\MyWorkspace\MyProject\MyProject_rc\MyProject_rc.o"
'MyWorkspace' and 'MyProject' replace with whatever is fitting for your purpose.

You have to add the folder .\MyProject_rc before you build.

The path to windres.exe must be known to eclipse.
Oct 23, 2013 at 1:38am
Thanks so much it was so cool to have a icon on my game it is so cool thanks so much.
Topic archived. No new replies allowed.