# Making Icons for C++ programs



## RAMAddict (Jul 7, 2004)

How do I make myself an icon for my C++ program? I mean I know how to make an icon but I don't know how ot use that certain icon for my program. I want to make a desktop icon for my C++ program. Thanks


----------



## Arky (Aug 17, 2004)

Your compiler must have an image editor or resource compiler. With one of those you create a resource containing icons for your project that your compiler will pick up on compilation. Exactly how will depend on what compiler you are using.


----------



## Shadow2531 (Apr 30, 2001)

With gcc/mingw, you make a resource file to include icon files. You use it to build an object file.

windres -i file.rc -o icons.o

g++ -Wall -W file.cpp icons.o -o file.exe

An example of an rc file to make the exe have an icon

*IDI_ICON1 ICON DISCARDABLE "file.ico"*

save as file.rc

(make sure there's a new line at the end of the file.


----------



## RAMAddict (Jul 7, 2004)

wait how do I set that up I don't know what to do


----------



## Shadow2531 (Apr 30, 2001)

O.K.

Make your program.
Save it as file.cpp.
Put your file.ico icon file in the same directory as file.cpp

Open a text editor and type the following on the first line.

*IDI_ICON1 ICON DISCARDABLE "file.ico"*

(press enter to create a newline)

Save it as file.rc.

At the command line (in the directory where the files are at), type the following command

*windres -i file.rc -o icons.o*

That will create the object file *icons.o* that you need to include when you build file.exe.

Then compile your program.

g++ -Wall -W file.cpp *icons.o* -o file

That will create file.exe which has file.ico as its built-in icon.


----------



## RAMAddict (Jul 7, 2004)

I get errors
No such file or directory
-x c after last input has no effect

I did everything up the the command line than I typed that in and it didn't work


----------



## RAMAddict (Jul 7, 2004)

I think this could be the problem, their icons are like a text file icon not like the other icon for the other .cpp on my desktop. I don't know why because I didn't save it as a text...


----------



## Shadow2531 (Apr 30, 2001)

Try it with this icon .

and change the rc file to

IDI_ICON1 ICON DISCARDABLE "newzoom.ico"


----------



## RAMAddict (Jul 7, 2004)

nope. I know what the problem is. When I try to save a new .cpp file or .rc file it won't let me and hit all programs and its not saved as a text and I type file.cpp or file.rc and I hit save and it still saves it has a text filefor some reason with the name file.cpp I don't know why its doing this


----------



## RAMAddict (Jul 7, 2004)

ah I figured it out myself everything works now with the icons
Thanks a bunch


----------



## Shadow2531 (Apr 30, 2001)

Oh I think I see. Win98 notepad was saving file.cpp as file.cpp.txt on you.

Glad you got it to work.

You should probably check

MyComputer
tools
folder options (folder options might be under "view" menu if your IE version is old)
view tab
uncheck "hide extensions for know file types"
and while you are at it, choose to show hidden files etc.

If you need a better text editor, you can try

metapad or crimson editor

Both are free, but crimson editor is better. Metapad does supports transparency though, but only for >= win2k

Crimson Editor is very close to edit plus (which is not free, but is the best editor).

There are many more editors, if you find those don't suit you, I can list more.


----------

