A few words of thanks would be greatly appreciated.

The resources in C/C ++


Resources can often be useful for the final version of a program, or before. This is to store images, fonts, cursors, dll, or even another program within the program itself, in the same folder or subfolders.


Standard Use

To use the resources with C/C + +, it must create a file extension ".rc", and place it in the same folder as the other project files.

Example: Content of the "game" folder with codeblocks:
  • Source Files
    • main.c
    • functions.c
  • File headers
    • headers.h
    • globalesVar.h
  • Resource file
    • res.rc
    • Other
  • game.layout
  • game.depend
  • game.cdp

The file is therefore in the same folder as other files.
In a resource file, there must be one attachment per line and a line must begin with a number.
  • Example:

ICON "icon.ico" 
RCDATA "otherProgram.exe"
  • Note that: If a file is located in a subfolder, you must specify this subfolder:

1 ICON "icons/icon.ico"

Use with Qt

The use of resources may also be useful with Qt, under C ++. Here, the principle is not the same. The resources are not find in a file with the .rc extension but with the extension: . qrc
It should be noted in file..pro" in the # input section, in this way:


RESOURCES += res.qrc

Here is the structure that must have your .qrc:

This is similar to the syntax of HTML. The files are integrated between the tags "<file>" and "</ file>".

Note that


A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « The resources in C/C ++ », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!