FaqCndResourceFiles

HOW TO CREATE AND ADD RESOURCE FILES INTO PROJECTS

Consider a sample project with three files involved:

ids.h
a CPP header file which is included in the resource file.
resource.rc
the resource file itself.
main.cpp
the main CPP program file.


I am making the supposition that you know how to create an header file and the main program file, but... You should have some knowledge about how to write .rc files, before to use them. If you need more informations about resources.rc files here's the msdn documentation, then how to create a resource file?

CREATING A RESOURCE FILE

  • Create a new file in a way that would be easiest for you, for example: Click on File menu, then New File, Other type File and finally select an Empty File.
  • Select a proper name for your resource file and click on Finish.
  • Write the code for your resource file and Save changes (for this tutorial I have chosen resource.rc).
File:Fig_FaqCndResourceFiles._1.JPG

ADDING A RESOURCE FILE INTO A PROJECT

Now we have all three files and so we will add resource.rc into our project using the following steps:

  • Right-click on resource.rc and select properties. Now we are in File Propierties - resource file.
  • On Categories -> General be aware that in Item Configuration under Tool you want to be sure Custom Build Tool is selected in list.
File:Fig_FaqCndResourceFiles._2.JPG
  • Fill out the following fields as shown below:
File:Fig_FaqCndResourceFiles._3.JPG
Command Line: windres.exe resource.rc resource.o
Since I am using MinGW I will use MinGW’s resource compiler windres.exe. You should enter the resource compiler you are currently using with its proper options.
Description: Compiling resources…
Here you can optionally write text which will be printed on screen during project’s compiling process.
Outputs: resource.o
Outputs are files generated by the command line we have entered before, in this case the only output is resource.o.
Additional Dependencies: ids.h
In this option we write files which are included into our resource file. (i.e. #include “ids.h”).
  • Apply changes and press OK button.
  • At this point we need to setup project’s properties: right-click on project’s name and select Properties, then click on Linker configuration.
File:Fig_FaqCndResourceFiles._4.JPG
  • Click on Libraries, then on Add Option, select Other Option, finally enter the name of the compiled resource file, in this case resource.o, and press OK button.
File:Fig_FaqCndResourceFiles._5.JPG
  • Next step consists of adding Additional Dependencies from Project Propierties context menu (see step number 5) , enter the resource file’s name and press OK button.
File:Fig_FaqCndResourceFiles._6.JPG
  • Finally we must Apply changes and press OK button.

Thus we have added a resource file (resource.rc) into our project.

Created by Novalida 2009

Edited by piBYe July 31 2009

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo