I’ve read a lot about how to add an icon to an application built with Visual Studio, but I have no idea how to do this with Eclipse Galileo / C / MinGW.
Can anyone write a description, or give me a link ta a description ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In Windows, the icons as well as some other elements (cursors, bitmaps, …) have to be specified in a resource file, which once compiled will be linked to the program.
First an example on how to add an icon to a Windows program which will illustrate it’s use within Eclipse. Here is a simple program that just creates a window, look at the time we fill the WNDCLASSEX, the icon of the application is referenced there:
resources.h – this file may be used to assign a value to a resource identifier, and so use the value instead:
The next file is the resources file, you may create it manually or from within Eclipse as well, to create it in Eclipse, right click the directory you want it to be (in this case is
src) and selectNew -> File. There write the name you want and clickFinish. To edit it from within Eclipse right click it and selectOpen with -> Text Editor.resources.rc – the icon will be specified here:
demoicon.c – the file containing the code of the program:
Now, in your Eclipse project source directory make sure you have all the files (in the example the 3 files mentioned before and the icon file).
After that go to
Project -> Properties.There, go to
C/C++ Build -> Settings -> Build Stepstab.There you’ll see
Pre-build steps -> Command. The command you fill in there will be executed before the compilation starts, so you’ll tell it to compile the resource file. As you are using MinGW the resource compiler iswindres:As you can see I’ll be placing the compiled resource file in a directory called
Resources, you may leave it where you want (and so the name of the file, it doesn’t have to be namedresources.rc).Now go to the
Tool Settingstab.There, go to
MinGW C Linker -> Miscellaneous, and in other objects add the object file created before, in this case you should add:As this is a Windows app, add the option
-mwindowsto the linker flags at the top of the same tab.Done, when building your project Eclipse will compile the resource file first and then link the generated object as any other object file of your project.
I hope it’s clear enough to read through this.