I am trying to add a resource file to include an icon for my win32 form application in Code::Blocks. I created the resource.rc file and added it to my project, and placed my icon in the root folder of the project (where the source files are), and I keep on receiving a preprocessing failed error.
This is what my resource.rc file looks like
#ifndef _resource_rc
#define _resource_rc
MAINICON ICON "icon1.ico"
#endif
My main.cpp file is just a untouched win32 form application, and the project itself is untouched besides adding the resource.rc file to the project.
The build message error is
||preprocessing failed.|
||=== Build finished: 1 errors, 0 warnings ===|
And the build log is
gcc: Files\: No such file or directory
gcc: \(x86\)\CodeBlocks\MinGW\include: No such file or directory
windres.exe: preprocessing failed.
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
I have checked to make sure where Code::Blocks is installed and it is located in \Program Files(x86)\ where as it seems gcc is looking at a folder called \(x86)\. May this be the problem?
If I remove the resource file, the application compiles and runs correctly.
Thanks for any help.
edit: I've enabled full compiler output and here is what is being ran:
windres.exe -i C:\Users\user\Desktop\MENOET~1\resource.rc -J rc -o obj\Debug\resource.res -O coff -I"C:\Program Files (x86)\CodeBlocks\MinGW\include"
gcc: Files\: No such file or directory
gcc: \(x86\)\CodeBlocks\MinGW\include: No such file or directory
windres.exe: preprocessing failed.
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
What I've noticed is that MENOET~1 is some sort of abbreviated name of my project directory and that is not its actual name. Not sure if that has anything to do with it, and I cant seem to change it.
edit2: I managed to fix it, but I rather not do it this way. What I did was copy MingGW to C:\ and then went Settings -> Compiler and debugger -> Search directories -> Resource compiler, and set that path to C:\MingGW\include. This allowed relieved all the errors and the build was successful, although I would much rather not have to have copies of MingGW in my root C:\ directory. Is there any way to fix this so it would work with the original path? I'd imagine it is just goofing up on the spaces in the file name, but I cant figure out where to find the build variables to insert quotes.
\(x86\)\- as in the\inside the brackets. I just checked my setting for "Settings->Compiler->Search directories->Resource compiler", finding it to be empty. While the entry under '...directories->Compiler' isC:\Program Files (x86)\CodeBlocks\MinGW\include. You can always try re-installing it. I've done that for a reason I've long since forgotten, in the past. EDIT: meant to say (1) there's no include file in your resource.rc (I'd expect resource.h, which had something like#define MAINICON 100) (2) Checkout ResEdit - www.resedit.net