0

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.

2
  • I can't help but notice this: \(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' is C:\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 Commented Nov 24, 2013 at 1:48
  • @enhzflep I'll try removing the search directory from codeblocks and see what happens, although I do have it functioning as of now, although not how I would like. Thanks for the suggestion. Commented Nov 24, 2013 at 2:00

1 Answer 1

1

As per my deductions and enhzflep's settings, I have fixed the problem. The problem is caused by spaces and characters such as brackets being in the path name of the search directories for the resource compiler.

In order to fix this, either move any directories in the resource compilers search directory to C:\ as to remove spaces from it's name, or remove its reference from code::blocks completely.

Both methods worked. Moving the MingGW directory into C:\ and then setting the new search path to C:\MingGW\include fixed this error as well as just removing any reference to this folder in the resource compiler menu.

Both allowed the application to compile successfully.

You can find the resource compiler search directories under

Settings -> Compiler and debugger -> Search directories -> Resource compiler

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.