Linking, Icons and Code::Blocks

After working with other compilers that easily let you select the desired icon prior to compiling the executable, I wondered how the same could be acheived with Code::Blocks 12.11. I stumbled across a forum on Daniweb, where Duoas covered the basics. Yet, no matter what I cannot get it to compile, despite following his suggestion that I ensure the correct compiler settings.

main.cpp
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include "resource.rc"

using namespace std;

int main()
{
    cout<<"TESTING...";
    return 0;
}

resource.rc
1
2
3
4
5
#ifndef RESOURCE_RC_INCLUDED
#define RESOURCE_RC_INCLUDED

MYICON ICON "Bart.ico"
#endif//RESOURCE_RC_INCLUDED 

I have told Code::Blocks to add the icon file, and have also manually added it to my working directory. So the project tree looks like this:
1
2
3
4
5
6
7
8
    [-] Workspace
         [-] Test
              [-] Sources
                   | |_ main.cpp
              [-] Resources
                   | |_ resources.rc
              [-] Others
                   | |_ Bart.ico

Yet no matter what I try, I get the following error, despite following the instructions to the letter.
MYICON does not name a type

What am I doing wrong?
Last edited on
a resource file is a script that gets linked in the program by windres so remove line 2 and it should work. You are mistaking the resource file as a c/c++ file.

[edit]
added link below:
http://msdn.microsoft.com/en-us/library/7zxb70x7.aspx
Last edited on
Thanks giblit. Now, the executable has the desired icon, but remains generic looking within the title bar and on the taskbar. Apparently unlike a header, which you add to the project and also include as I did on line 2, apparently simply adding the rc file alone is enough, but only applies to the executable viewed within Windows Explorer itself.

But I still get a blank, generic looking icon on program execution. It does not seem to matter whether it is a console based application or not, either. I had the same results applying this to a simple SFML based program I made.

How can I get my executable to show up in the title bar, or on the taskbar when active? I realize this may not even be possible in the console (and don't really care), but shouldn't it possible otherwise? Perhaps I need to look into SFML further, as I am fairly new to it. I've also been studying Win32API, but I've been overloaded lately and haven't gotten very far.
Last edited on
Topic archived. No new replies allowed.