Retrieve build version [Solved]



  • hi,

    this a "simple" question that strangely I didn't found anywhere else in this forum and Google too :

    I need to display the build version of my software (like the one you got in the "about" dialog), please
    indicate me what to do .

    PS : I found a blog that indicates to modify the .pro with a @Version=1.2.3@
    to read it from main.cpp but that didn't worked for me



  • maybe it will work:

    .pro file:
    @DEFINES += MYVERSION=1.2.1
    VERSION = MYVERSION@

    and you also can use define MYVERSION in C++ code.



  • Displaying version information can be nasty. There are a few practices for this.

    • Using preprocessor defines at build time
    • Using a version header file (with defines), which can be versioned and updated by a version bump tool or automatically generated by a source control tool (especially useful for build or revision numbers)
    • Using the .rc file on windows
    • Whatever we can think of...

    The VERSION thingy in the .pro file is mainly useful for a soname, but might (no experience) be used for your application as well.

    The reason you cannot really find a lot of information on it is probably because handling version information hasn't been standardized in a cross-platform or generally applicable manner in any way.



  • first of all : thanks for your answers.

    Alexander : this didn't worked for me with a read of VERSION from my main.Cpp

    Franzk : I better understand why this is so hard, nevertheless why not about a "Qt-way" resource for that purpose. This is just a think anyway.

    At last , the #define Version 1.2.3 is the same as the .pro modification (that didn't worked for me)
    In fact, I really like to be a real auto-generated number, not one I did by hand : what do you call a

    bq. version bump tool ?



  • As I know, VERSION in .pro file is used in symbian (when you install sis file).
    You can use @define MYVERSION@ in C++ code.
    For example, in our project, build system generates version.h file with @#define VESRION 1.1.0.svn revision number@
    and all modules of our program use this define.



  • this is really interesting as I mainly target symbian platform.

    Nevertheless as I said, this is a manual versioning.



  • [quote author="doubitchou" date="1296570480"]what do you call a
    bq. version bump tool ?[/quote]
    It's usually a (custom) script that increases the version number, rewrites some file with the version definitions and creates a tag or label in the vcs (git, svn whatever).



  • how :-( , thought there were some tools to do that for me (lazy I am).



  • Could still be, but then you'd have to invest some time in searching :P



  • exact, no better done than by myself.

    A good idea would be to use QtCreator for that purpose :

    • in the pre-build process configuration I'll add a call to a little soft that increment a version number
      in a local file.

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.