1

I am working in MinGW environment (downloaded with their installer on 12/12/2011). I am attempting to compile a resource (.rc) file using Windres. The specific command I use is

Windres -O coff About1.rc -o About1.res

Windres generates at least 100 lines of warning messages reading: "warning: null characters ignored". Following this Windres emits: "Abouty1.rc:1:syntax error".

As a matter of fact, there are no null characters in the About1.rc file. In addtition, the first line of the file is an include statement: #include "dlgresource.h". I played around and eliminated this statement and it turns out that it doesn't matter what I put there, I get the same flurry of messages and the syntax error notification.

To make things more confusing, this same .rc file compiles without any problem using MSFT's rc.exe. The resulting .res file links smoothly with the program .obj file and runs perfectly.

I have no idea what is going on. Any ideas?

Thanks, Mark Allyn

allynm
  • 221
  • 4
  • 7

4 Answers4

5

Your .rc file is probably encoded as UTF-16.

That's what's required in general by Microsoft's [rc.exe], in order to be able to deal with international characters, but GNU [windres.exe] can only deal with ANSI encoding.

One workaround is to convert the file to ANSI on the spot (possibly losing e.g. Russian or Greek characters):

> chcp 1252
Active code page: 1252

> type my.rc | windres --output-format=COFF -o my.res

> _
Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
1

You probably used VS or a similar tool to generate the file. There are some parts of the character encodings that you cannot see resulting in null characters and etc.

Generate a new .res file with the same content, don't copy/paste the content, type it in yourself.

Secko
  • 7,664
  • 5
  • 31
  • 37
0

Try:

    windres About1.rc -o About1.o

and then just use the resulting .o file instead of the originally intended .res file.

0

I've had the same troubles than you today. I know it has passed a lot of time from your question, but I'm writting this on the hope that it can be useful for someone.

First, I obtained an object file .o compiled using Cygwin, writting:

windres -o resource.o resource.rc

By doing that, you dont need to use the .res file, but the .o one, and you can then link this object with all the others, when you compile yout program, using GNU resources:

g++ Header_files CPP_files flags ... -o program.exe recource.o -lm

For instance.

elcortegano
  • 2,444
  • 11
  • 40
  • 58