我试图让 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 文件在我的包含目录中,我手动检查。另外,.cpp 文件使用它并且它没有编译失败。
编辑 4:删除包含 windows.h 文件的行不会改变任何内容,它仍然会给出相同的错误。
编辑 5:直接按字符串而不是按名称命名每个类并消除所有错误消息。