System Requirements Get The Source From GitHub Install The Cocotron Development Tools Build The Cocotron Frameworks Set Up A Project To Build With Cocotron Build A Project With The Cocotron Development Tools Windows App Icon Linux/BSD cross-compilation platform interface

Adding an Application Icon

aka

Compiling Windows Resource Files

Unfortunately I don't have a nice tool in the CDT which automatically takes your Mac icon, generates a Window icon, generates a resource file and compiles the two so that your Application icon Just Works, and it would be even nicer if it read in Info.plist too and generated the document icons. So, you have to do it manually.

binutils comes with a Windows resource compiler called windres.

CDT includes an Xcode file specification for .rc files.

Steps to add an application icon

- Create a Windows .ico file for you application icon, say Application.ico, there are a number of programs out there that will convert a Mac .icns to a Windows .ico, and maybe even let you edit it if you so desire.

- Create a Windows resource file, say Icons.rc, in your project and add it to the Windows target only. It should look like this:

app      ICON    Application.ico
ICONS1   ICON    Application.ico

Those are tabs in there. I don't know if windres cares or not, but tabs work. You can add more icons using ICONS2, ICONS3, etc. You'll need to do that for document icons.

- Create a Rule in the Windows target which looks like this:

Process: Windows resource files

using: Custom script:

/Developer/Cocotron/1.0/Windows/i386/gcc-4.0.3/bin/i386-mingw32msvc-windres $INPUT_FILE_PATH -O coff -o $OBJECT_FILE_DIR_normal/$ARCHS/$INPUT_FILE_BASE.o

with output files: (click +)

$(OBJECT_FILE_DIR_normal)/$(ARCHS)/$(INPUT_FILE_BASE).o

Xcode will now compile any .rc file in your project, in this case the Icons.rc, link the resulting .o with the rest of them and your .exe now has an icon embedded in it which Windows understands to be your application icon.

Document icons are more involved as you need to modify the registry to create associations between file extensions, an icon and your executable. This is a more general Windows thing, but I might write about it, or you can.