Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding build date to linux project
Qt 6.11 is out! See what's new in the release blog

Adding build date to linux project

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 3.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SPlattenS SPlatten

    I found this online:

    https://www.qtcentre.org/threads/5192-show-build-date-in-about-box

    In my .pro file I added:

        DEFINES += "BUILDDATE=system(date +'%d-%m-%y %T')"
    

    However this results in an error:

        [main.o] Error 2
    

    Not terribly helpful, but that's all it shows, if I comment out the DEFINES and rebuild it will build without the error.

    How do I solve this?

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @SPlatten From the link:
    "Didn't you forget the $$? I can't test it for linux right now but to make it work for winxp as well it should be:
    Qt Code:
    Switch view

    win32:DEFINES += BUILDDATE=$$system(date /t)"
    

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    4
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #3

      $$system() not system().

      Here is a working example: https://github.com/milosolutions/mwizardtemplate/blob/master/version.pri

      (Z(:^

      1 Reply Last reply
      5
      • SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #4

        Thank you, I couldn't find an example for linux, will try your suggestion now.

        Kind Regards,
        Sy

        1 Reply Last reply
        0
        • SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by SPlatten
          #5

          My entry now reads:

              DEFINES += "BUILDDATE=$$system(date +\"%d-%m-%y %T\")"
          

          Now I get:

              No such file or directory
              File not found: arm-argo-linux-gnueabi-g++: 0906
          

          Also keep in mind, I'm developing on Linux not Windows.

          [Edit] Solved, changed line to:

              DEFINES += BUILDDATE=$$system(date +"%d-%m-%y %T")
          

          [Edit 2] Actually, not completely solved, although the application now compiles, I still get no build date:

              QString strBldDate(BUILDDATE);
          

          Its empty.

          Kind Regards,
          Sy

          1 Reply Last reply
          1
          • SPlattenS SPlatten

            I found this online:

            https://www.qtcentre.org/threads/5192-show-build-date-in-about-box

            In my .pro file I added:

                DEFINES += "BUILDDATE=system(date +'%d-%m-%y %T')"
            

            However this results in an error:

                [main.o] Error 2
            

            Not terribly helpful, but that's all it shows, if I comment out the DEFINES and rebuild it will build without the error.

            How do I solve this?

            CP71C Offline
            CP71C Offline
            CP71
            wrote on last edited by CP71
            #6

            @SPlatten
            Hi,
            maybe it isn’t what you want, if you don’t need in your PRO but in your source I use:

            char* data_ver = (char*)__DATE__;
            char* time_ver = (char*)__TIME__;

            ui->buildValue->setText(QString("%1 %2").arg(data_ver).arg(time_ver));

            1 Reply Last reply
            1
            • SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #7

              Thank you, but won't that only give the date and time of the source file that its implemented in, I want the system date and time at the time of build.

              Kind Regards,
              Sy

              jsulmJ 1 Reply Last reply
              1
              • SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by
                #8

                Is there any good source of information or tutorial on how to use definitions in the .pro file?

                I've been told I can use message() in a .pro file and I have to view:

                    message($$system(date +\"\\\"%d-%m-%y %T\\\"\")
                

                And this works well, I can see in the General Messages pane when I build something like:

                    Project MESSAGE: "26-06-19 10:55:11"
                

                How can I use this to review the content of a definition? I've tried:

                    message(BUILDDATE)
                

                Just results in:

                    Project MESSAGE: BUILDDATE
                

                I also tried:

                    message($$BUILDDATE)
                

                The result is:

                    Project MESSAGE:
                

                So if the last one is correct, nothing is being assigned to BUILDDATE, how do I fix this?

                Kind Regards,
                Sy

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #9

                  You can print whole DEFINES like this:

                  message($$DEFINES)
                  

                  (Z(:^

                  1 Reply Last reply
                  3
                  • SPlattenS SPlatten

                    Thank you, but won't that only give the date and time of the source file that its implemented in, I want the system date and time at the time of build.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @SPlatten said in Adding build date to linux project:

                    but won't that only give the date and time of the source file that its implemented in

                    https://www.cprogramming.com/reference/preprocessor/__DATE__.html
                    "__DATE__ is a preprocessor macro that expands to current date (at compile time)"

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    4
                    • SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #11

                      Thank you the output is:

                          Project MESSAGE: QT_QWS_CLIENTBLIT BUILDDATE=26-06-19 11:20:37
                      

                      Kind Regards,
                      Sy

                      1 Reply Last reply
                      0
                      • SPlattenS Offline
                        SPlattenS Offline
                        SPlatten
                        wrote on last edited by SPlatten
                        #12

                        I will be abandoning the exploration of creating a definition from the system date and instead use DATE and TIME.

                        How do I prevent the editor from changing the text on the date and time fields?

                        Kind Regards,
                        Sy

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved