Search code examples
c++winapigccwindres

windres fatal error: when writing output to : Invalid argument


I was trying to make windres compile a resource file from Visual Studio. I properly converted all the files (and the one included) to ANSI, but I still get this error every time I try to compile it :

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))

Here is the start of the source code of the corresponding file :

#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

EDIT : Note that I looked at the .rc file with a hex editor and all the newlines are fine, the conversion to ANSI worked properly

EDIT 2 : The path to the .rc file doesn't have any spaces or anything that should screw with windres :

C:\Users\Gabriel\Documents\DoConfig\DoConfig\DoConfig.rc

EDIT 3 : The windows.h file is in my include directory, I checked manually. Plus, the .cpp file uses it and it didn't fail to compile.

EDIT 4 : Removing the line that includes the windows.h file doesn't change anything, it still gives the same error.

EDIT 5 : Naming every class by string instead of by name directly worked and eliminated all error messages.


Solution

  • Control's class name should be "BUTTON", not BUTTON

    Button_Use_Gamepad should be defined as an integer

    Corrected format:

    CONTROL "Use Gamepad", 101, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 16, 100, 12