Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: The Techo on July 29, 2009, 06:35:52 am

Title: Icon Help
Post by: The Techo on July 29, 2009, 06:35:52 am
Hello I am new to Code Blocks, c++ and Win32 programming. i need help on Icons i have an icon in my project's root folder with a icon named o.ico. in my .rc I typed:

#include "Resource.h"

IDI_main ICON "o.ico"

In my resource file I typed:

#define IDI_main 1000

And in my .cpp file I typed:

..........More code.......
   WndClsEx.hIcon         = WndClsEx.hIconSm       = LoadIcon(hInstance,
                 MAKEINTRESOURCE(IDI_main));
   WndClsEx.hCursor       = LoadCursor(NULL, IDC_ARROW);
   WndClsEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
   WndClsEx.lpszMenuName  = NULL;
   WndClsEx.lpszClassName = ClsName;
   WndClsEx.hInstance     = hInstance;
   WndClsEx.hIconSm       = WndClsEx.hIconSm       = LoadIcon(hInstance,
                 MAKEINTRESOURCE(IDI_main));
..........More code.......
 
But when i compile i get the following:

||warning: `-x c' after last input file has no effect|
||preprocessing failed.|

can someone please help me?
Title: Re: Icon Help
Post by: MortenMacFly on July 29, 2009, 08:01:24 am
||warning: `-x c' after last input file has no effect|
||preprocessing failed.|
First of all -> this error is not related to your code. I assume your project setup / compiler options, linker options etc. are mis-configured. Please enable full compiler logging and post the result here (see my sig how to do that).
Title: Re: MortenMacFly
Post by: The Techo on July 29, 2009, 10:38:58 am
I did what you said and in the build log I got the following message:


-------------- Build: Debug in test ---------------

windres.exe -i C:\DOCUME~1\ADMINI~1\Desktop\CTESTS~1\test\1.rc -J rc -o obj\Debug\1.res -O coff -I"C:\Documents and Settings\Administrator\Desktop\C Tests\test\"
gcc: and\: No such file or directory
gcc: Settings\Administrator\Desktop\C\: No such file or directory
gcc: Tests\test C:\DOCUME~1\ADMINI~1\Desktop\CTESTS~1\test\1.rc: Invalid argument
gcc: warning: `-x c' after last input file has no effect
gcc: no input files
windres.exe: preprocessing failed.
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 1 warnings
  


Is this what you wanted?

P.s. I am using the gcc compiler which is included with the installation package
Title: Re: MortenMacFly
Post by: MortenMacFly on July 29, 2009, 11:13:45 am
windres.exe -i C:\DOCUME~1\ADMINI~1\Desktop\CTESTS~1\test\1.rc -J rc -o obj\Debug\1.res -O coff -I"C:\Documents and Settings\Administrator\Desktop\C Tests\test\"
gcc: and\: No such file or directory
That's what I wanted. And as you see: You have an issue with spaces in the path. Some resource compilers do *not* support that - as yours.

You now have the following options:
1.) Move your project to a folder without spaces in the path
2.) Update the compiler suite to a more recent one - especially the resource compiler (which depends on the other compilers, to so do *n ot* only update the resource compiler).
3.) In the compiler setup under "other settings" click on the "advanced options". Then select the tab "Others" and enable "force quotes for filenames in compiler command-line", probably the same for the linker.

The latter may not work or even break the compilation, too if not done with care.
Title: Re: Morten Mac Fly
Post by: The Techo on July 29, 2009, 12:08:40 pm
Thanks it works perfectly :D