News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Icon Help

Started by The Techo, July 29, 2009, 06:35:52 AM

Previous topic - Next topic

The Techo

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?

MortenMacFly

Quote from: The Techo on July 29, 2009, 06:35:52 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).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

The Techo

#2
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

MortenMacFly

Quote from: The Techo on July 29, 2009, 10:38:58 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

The Techo

Thanks it works perfectly :D