Trying to add icon

I am trying to add a icon to a C++ project in eclipse to the exe itself.
Last edited on
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 

ya i know im trying to find out how to add it in eclipse.
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.
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.