Cross-Compiling Windows Resources

From WxWiki
Jump to: navigation, search

This page shows how to embed icons (.ico files) into your executable when you're compiling Windows executables under Linux (called `cross-compiling') with mingw32.

First you make a resource (.rs) file. This looks like:

 in ICON "icons/AltInBox2.ico"
 proc ICON "icons/AltOutBox2.ico"
 out ICON "icons/AltOutBox.ico"

You can compile that into an object file like this:

 i586-mingw32msvc-windres -o resources.o

Then in your application you can use the icons like this:

wxIcon icon1 (wxICON(in));
wxIcon icon2 (wxICON(proc));
wxIcon icon3 (wxICON(out));

(See WxIcon: this automatically fixes things up so you're using XPM icons when compiling for Linux)

Finally you just link the resources.o file into your executable and you're done! Sweet, eh?