1

I'm trying to compile a C program with a icon attached.

I'm following this instructions: How do I add an icon to a mingw-gcc compiled executable?

Both Evan's and Steven's replies.

I'm getting this error 4x:

ico.rc:1: unrecognized escape sequence

when I run:

windres ico.rc -O coff -o ico.res

The working dir is where the executable, source file and 'icon.ico' files are. The icon is just an png converted with

ffmpeg -i icon.png icon.ico

The '.rc' file content is:

id ICON ico.ico

My machine is a Windows 10 32-bits with MINGW, without Microsoft Visual Studio.

How can I compile my program with an icon?

Community
  • 1
  • 1
  • ico.ico should be in double quetes? – nsilent22 Jan 24 '16 at 18:18
  • I tried with quotes, without quotes, full path and only file name, escaped backslash and not escaped backslash. Always same error. – RicardoMazeto Jan 24 '16 at 18:36
  • perhaps the contents of ico.rc is unicode or the wrong unicode? – GroovyDotCom Jan 25 '16 at 00:17
  • If the size of your RC file is > 20 bytes, you have unicode and should convert it to ascii. – GroovyDotCom Jan 25 '16 at 00:34
  • If the contents are like described (`echo "id ICON ico.ico" > ico.rc`), something odd is happening. At least I could generate *ico.res* using windres and a image I converted with `convert -geometry 120x120 image.png ico.ico`. ffmpeg is probably a little bit odd choice for doing that conversion. – J.J. Hakala Jan 25 '16 at 08:51
  • @GroovyDotCom I saved ico.rc with ANSI and it worked! I did it yesterday but it wasn't working, maybe that's because I restarted my machine since then. Who knows. Nevertheless thank you! – RicardoMazeto Jan 25 '16 at 16:14
  • @J.J.Hakala I didn't know that convert could be used to convert images. Isn't convert used to convert FAT into NTFS? On my machine it returns "Invalid Parameter - 120x120". – RicardoMazeto Jan 25 '16 at 16:23
  • @RicardoMazeto it is a part of ImageMagick software, http://www.imagemagick.org/script/binary-releases.php – J.J. Hakala Jan 25 '16 at 17:38

1 Answers1

0

I was searching for the same problem, and found the solution in another site (https://dev-cpp-users.narkive.com/AEWfAsk2/dev-c-problem-with-resource-files), so here I am to share it:

doesn't work because you need to use forward slash (/) as directory seperator - backslash does not work.

Changing the slashes inside the .rc file was enough for it to work (in cause you also need slashes in the windres command, it can be ). Also, the path inside the .rc file doesn't like accents (eg: áàé).

Edit: I just noticed that the How do I add an icon to a mingw-gcc compiled executable? post says in the example

"path/to/my.ico"

not

"path\to\my.ico"

Benur21
  • 109
  • 7