Important: Please read the Qt Code of Conduct -

Can't use RC file

  • Hi
    I would like to display information in detail in my executablelike company name version etc.
    so I made this rc file:

    #ifndef RCFILE_H
    #define RCFILE_H
    #include "../svn_version.rc"
    IDI_ICON1               ICON    DISCARDABLE     "../res/mediasofts.ico"
    #define VER_FILEVERSION             1,0,0,0
    #define VER_FILEVERSION_STR         "\0"
    #define VER_PRODUCTVERSION          1,0,0,I_SVNREVINT
    #define VER_PRODUCTVERSION_STR      "1.0\0"
    #define VER_COMPANYNAME_STR         "Médiasofts"
    #define VER_FILEDESCRIPTION_STR     "Mediacad drawing software"
    #define VER_INTERNALNAME_STR        "Médiacad"
    #define VER_LEGALCOPYRIGHT_STR      "Copyright © 2016 Médiasofts"
    #define VER_LEGALTRADEMARKS1_STR    "All Rights Reserved"
    #define VER_ORIGINALFILENAME_STR    "Mediacad.exe"
    #define VER_PRODUCTNAME_STR         "Mediacad"
    #define VER_COMPANYDOMAIN_STR       ""
        BLOCK "StringFileInfo"
            BLOCK "040904E4"
                VALUE "CompanyName",        VER_COMPANYNAME_STR
                VALUE "FileDescription",    VER_FILEDESCRIPTION_STR
                VALUE "FileVersion",        VER_FILEVERSION_STR
                VALUE "InternalName",       VER_INTERNALNAME_STR
                VALUE "LegalCopyright",     VER_LEGALCOPYRIGHT_STR
                VALUE "LegalTrademarks1",   VER_LEGALTRADEMARKS1_STR
                VALUE "LegalTrademarks2",   VER_LEGALTRADEMARKS2_STR
                VALUE "OriginalFilename",   VER_ORIGINALFILENAME_STR
                VALUE "ProductName",        VER_PRODUCTNAME_STR
                VALUE "ProductVersion",     VER_PRODUCTVERSION_STR
                VALUE "Rev",     I_SVNREV
                VALUE "Date",     I_SVN_CLOCKDATE
        BLOCK "VarFileInfo"
            VALUE "Translation", 0x409, 1252
    #endif // RCFILE_H

    I have

    RC_FILE = mediacad.rc

    in my .pro but the compilation failed on RC with :
    ....\MediaCad\mediacad.rc(24) : error RC2135 : file not found: StringFileInfo
    ....\MediaCad\mediacad.rc(26) : error RC2135 : file not found: 040904E4
    ....\MediaCad\mediacad.rc(28) : error RC2135 : file not found: CompanyName
    ....\MediaCad\mediacad.rc(29) : error RC2135 : file not found: VALUE

    I don't know why it failed .
    Do you have an idea ?
    Is it possible to use RC file for DLL too ?

  • Hi, you forgot the version info title line, try change to this:

    #define VER_PRODUCTNAME_STR         "Mediacad"
    #define VER_COMPANYDOMAIN_STR       ""
        BLOCK "StringFileInfo"

  • Thanks, errors are gone but if I look the details of my executable
    (properties > details on windows) I did not found my information.

  • Hi, actually if you binary dump your .exe file you'll see your version info, but agreed it's nice to be able to see it in Explorer (properties->details).

    So, at the top of your .RC file add a Language statement to make the version info visible. (Need windows.h for LANG_ENGLISH etc, I think you can replace those with hex numbers if you don't like to include windows.h):

    #ifndef RCFILE_H
    #define RCFILE_H
    #include <windows.h>
    #include "../svn_version.rc"
    IDI_ICON1               ICON    DISCARDABLE     "../res/mediasofts.ico"
    #define VER_FILEVERSION             1,0,0,0

    Also to cover all the bases/fields in that properties->details dialog box, you can get fancy and add the Fileversion and Productversion lines:

    #define VER_COMPANYDOMAIN_STR       ""
        BLOCK "StringFileInfo"

    Hope this helps!

  • Thanks it works now.

  • Hi, thanks for this discussion.
    After implementing as per suggested by Roy44 and Hskoglund, I am able to see version info of my exe in File->property->Details.

    I have following questions:

    • It is showing FileVersion as What do I need to do for displaying my desired FileVersion there?
    • What do we need to do for Linux and MAC. As here we are including "windows.h", that may not work while compiling code on these OS.


  • Use the VERSION variable in your project file.

  • @mdnchauhan said in Can't use RC file:

    • What do we need to do for Linux and MAC. As here we are including "windows.h", that may not work while compiling code on these OS.

    RC files are a Windows thing. OSX and Linux use different approaches. So you don't need to concern about the #include <windows.h> in the RC file since they won't use it.

    OSX (Mac) uses a "Info.plist" file, that is a xml describing the application info in the following format:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
    <plist version="1.6">
    	<string>//Version goes here. something like 1.0.0//</string>
    	<string>//Some text you want to put here. something short like "Business® All rights reserved"//</string>
    	<string>//Bundle version. Usually the same thing as CFBundlePackageType//</string>
    	<string>//same thing as above//</string>

    Also you need to specify the path to the Info.plist in your .pro file:

    QMAKE_INFO_PLIST = /path/to/your/Info.plist

    My suggestion is to put it in the root of your project directory and use

    QMAKE_INFO_PLIST = $$_PRO_FILE_PWD_/Info.plist

    To set the application icon, just add to your .pro file:

    ICON = /path/to/icon.icns 

    I don't know how it works in Linux, though.

Log in to reply