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
Forum Updated to NodeBB v4.3 + New Features

Adding build date to linux project

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 1.6k 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.
  • S Offline
    S Offline
    SPlatten
    wrote on 26 Jun 2019, 07:51 last edited by
    #1

    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?

    Kind Regards,
    Sy

    J C 2 Replies Last reply 26 Jun 2019, 07:58
    0
    • S SPlatten
      26 Jun 2019, 07:51

      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?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 26 Jun 2019, 07:58 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
      • S Offline
        S Offline
        sierdzio
        Moderators
        wrote on 26 Jun 2019, 07:58 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
        • S Offline
          S Offline
          SPlatten
          wrote on 26 Jun 2019, 08:05 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
          • S Offline
            S Offline
            SPlatten
            wrote on 26 Jun 2019, 08:08 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
            • S SPlatten
              26 Jun 2019, 07:51

              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?

              C Offline
              C Offline
              CP71
              wrote on 26 Jun 2019, 08:54 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
              • S Offline
                S Offline
                SPlatten
                wrote on 26 Jun 2019, 09:29 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

                J 1 Reply Last reply 26 Jun 2019, 10:22
                1
                • S Offline
                  S Offline
                  SPlatten
                  wrote on 26 Jun 2019, 10:00 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
                  • S Offline
                    S Offline
                    sierdzio
                    Moderators
                    wrote on 26 Jun 2019, 10:17 last edited by
                    #9

                    You can print whole DEFINES like this:

                    message($$DEFINES)
                    

                    (Z(:^

                    1 Reply Last reply
                    3
                    • S SPlatten
                      26 Jun 2019, 09:29

                      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.

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 26 Jun 2019, 10:22 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
                      • S Offline
                        S Offline
                        SPlatten
                        wrote on 26 Jun 2019, 10:24 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
                        • S Offline
                          S Offline
                          SPlatten
                          wrote on 26 Jun 2019, 10:54 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

                          1/12

                          26 Jun 2019, 07:51

                          • Login

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