Windres语法错误
我正在 MinGW 环境中工作(于 2011 年 12 月 12 日使用安装程序下载)。我正在尝试使用 Windres 编译资源 (.rc) 文件。我使用的具体命令是
Windres -O coff About1.rc -o About1.res
Windres 生成至少 100 行警告消息:“警告:忽略空字符”。在此之后,Windres 发出:“Abouty1.rc:1:语法错误”。
事实上,About1.rc 文件中没有空字符。另外,该文件的第一行是一个包含语句:#include "dlgresource.h"。我尝试了一下并消除了这个语句,事实证明我放在那里的内容并不重要,我得到了同样的消息和语法错误通知。
更令人困惑的是,使用 MSFT 的 rc.exe 编译同一个 .rc 文件没有任何问题。生成的 .res 文件与程序 .obj 文件顺利链接并完美运行。
我不知道发生了什么事。有什么想法吗?
谢谢, 马克·艾林
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的 .rc 文件可能编码为 UTF-16。
这就是 Microsoft [rc.exe] 通常所需要的,以便能够处理国际字符,但 GNU [windres.exe] 只能处理 ANSI 编码。
一种解决方法是当场将文件转换为 ANSI(可能会丢失例如俄语或希腊语字符)
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):
您可能使用 VS 或类似的工具来生成该文件。字符编码的某些部分您看不到,从而导致空字符等。
生成具有相同内容的新 .res 文件,不要复制/粘贴内容,请自行键入。
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.
尝试:
然后使用生成的 .o 文件而不是最初的 .res 文件。
Try:
and then just use the resulting .o file instead of the originally intended .res file.
我今天也遇到了和你一样的烦恼。我知道你的问题已经过去很长时间了,但我写这篇文章是希望它对某人有用。
首先,我获得了一个使用Cygwin编译的目标文件
.o
,其中写道:通过这样做,你不需要使用
.res
文件,但是.o
一个,然后当您使用 GNU 资源编译程序时,您可以将此对象与所有其他对象链接:例如。
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: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:For instance.