我试图让windres从Visual Studio编译资源文件。我正确地将所有文件(以及包含的文件)转换为ANSI,但每次尝试编译时我仍然会收到此错误:
windres.exe -J rc -O coff -i C:\Users\Gabriel\DOCUME~1\DoConfig\DoConfig\DoConfig.rc -o Debug\DoConfig.res
mingw32-g++.exe -o ..\Debug\DoConfig.exe Debug\DoConfig.o Debug\stdafx.o Debug\DoConfig.res -lwinmm.lib -lcomctl32.lib -lkernel32.lib -luser32.lib -lgdi32.lib -lwinspool.lib -lcomdlg32.lib -ladvapi32.lib -lshell32.lib -lole32.lib -loleaut32.lib -luuid.lib -lodbc32.lib -lodbccp32.lib -mwindows
C:\Users\Gabriel\DOCUME~1\DoConfig\DoConfig\DoConfig.rc:4:0: fatal error: when writing output to : Invalid argument
^
compilation terminated.
windres.exe: C:\\Users\\Gabriel\\DOCUME~1\\DoConfig\\DoConfig\\DoConfig.rc:22: syntax error
windres.exe: preprocessing failed.
Process terminated with status 1 (0 minute(s), 3 second(s))
3 error(s), 0 warning(s) (0 minute(s), 3 second(s))
以下是相应文件源代码的开头:
#include "resource.h"
#include <windows.h>
IDI_DOCONFIG ICON "DoConfig.ico"
STRANGE_LAYOUT BITMAP "Strange_Layout.bmp"
NORMAL_LAYOUT BITMAP "Normal_Layout.bmp"
MENU_MAIN MENU
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
{
MENUITEM "Quit", 40001
MENUITEM "Note", 40002
}
DLG_CONFIG DIALOGEX 0, 0, 387, 281
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Doukutsu Monogatari - Settings"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
FONT 9, "Arial"
{
CONTROL "Use Gamepad", Button_Use_Gamepad, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 12, 16, 100, 12
CONTROL "", Button_Jump_1, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP, 52, 48, 12, 12
CONTROL "", Button_Attack_1, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 52, 64, 12, 12
CONTROL "", Button_Weapon_Plus_1, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 52, 80, 12, 12
CONTROL "", Button_Weapon_Minus_1, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 52, 96, 12, 12
CONTROL "", Button_Item_1, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 52, 112, 12, 12
CONTROL "", Button_Map_1, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 52, 128, 12, 12
CONTROL "", Button_Jump_2, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP, 68, 48, 12, 12
CONTROL "", Button_Attack_2, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 68, 64, 12, 12
CONTROL "", Button_Weapon_Plus_2, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 68, 80, 12, 12
CONTROL "", Button_Weapon_Minus_2, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 68, 96, 12, 12
CONTROL "", Button_Item_2, BUTTON, BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 68, 112, 12, 12
编辑:请注意,我使用十六进制编辑器查看了.rc文件,所有换行都没问题,转换为ANSI工作正常
编辑2:.rc文件的路径没有任何空格或任何应该使用windres的东西:
C:\Users\Gabriel\Documents\DoConfig\DoConfig\DoConfig.rc
编辑3:windows.h文件在我的include目录中,我手动检查。另外,.cpp文件使用它并且编译失败。
编辑4:删除包含windows.h文件的行不会改变任何内容,它仍会出现相同的错误。
编辑5:通过字符串而不是按名称命名每个类直接工作并消除所有错误消息。
答案 0 :(得分:1)
Control的类名应为"BUTTON"
,而不是BUTTON
Button_Use_Gamepad
应定义为整数
更正后的格式:
CONTROL "Use Gamepad", 101, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 16, 100, 12