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. use a string defined macro in *.pro file

use a string defined macro in *.pro file

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 3.1k Views
  • 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.
  • L Offline
    L Offline
    Limer
    wrote on 26 Apr 2019, 01:26 last edited by Limer
    #1

    I want define a macro just like CURRENT_APP_VERSION, and let it to the the value 0.0.6 (beta), and then I can use it in main.cpp,

    // main.cpp
    ...
    
    int main()
    {
        qDebug() << CURRENT_APP_VERSION;
    }
    

    And I google it , found the solution in https://forum.qt.io/topic/68933/use-qmake-variable-in-cpp-file/3# , but after I wrote them(just as the below codes) , and then compiled it, qt-creator gives me an error CURRENT_APP_VERSION is not defined.

    # my.pro
    
    VERSION = 0.0.6
    
    DEFINES += CURRENT_APP_VERSION=\"\\\"$${VERSION}\\\"\"
    

    What's wrong? (QMake version 3.1 Using Qt version 5.10.1 in D:/Qt/5.10.1/msvc2015/lib in Windows 10)

    A 1 Reply Last reply 26 Apr 2019, 04:13
    0
    • J jsulm
      26 Apr 2019, 07:09

      @Limer I don't see any of your APP_* defines being passed to the compiler.
      Did you actually rerun qmake after changing pro file?

      L Offline
      L Offline
      Limer
      wrote on 26 Apr 2019, 07:16 last edited by
      #11

      @jsulm Ohhhhhhhhhhhhhh, solve it. After I delete the build-HaiwellClient-Desktop_Qt_5_10_1_MSVC2015_32bit-Release
      directory, rebuild project, it success. Thanks a lot for your patient response.

      1 Reply Last reply
      1
      • D Offline
        D Offline
        dheerendra
        Qt Champions 2022
        wrote on 26 Apr 2019, 02:15 last edited by
        #2

        @Limer said in use a string defined macro in *.pro file:

        CURRENT_APP_VERSION

        You are doing the mistake in defined string. What you defined is CURRENT_VERSION. However printing the CURRENT_APP_VERSION.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        L 1 Reply Last reply 26 Apr 2019, 05:03
        4
        • L Limer
          26 Apr 2019, 01:26

          I want define a macro just like CURRENT_APP_VERSION, and let it to the the value 0.0.6 (beta), and then I can use it in main.cpp,

          // main.cpp
          ...
          
          int main()
          {
              qDebug() << CURRENT_APP_VERSION;
          }
          

          And I google it , found the solution in https://forum.qt.io/topic/68933/use-qmake-variable-in-cpp-file/3# , but after I wrote them(just as the below codes) , and then compiled it, qt-creator gives me an error CURRENT_APP_VERSION is not defined.

          # my.pro
          
          VERSION = 0.0.6
          
          DEFINES += CURRENT_APP_VERSION=\"\\\"$${VERSION}\\\"\"
          

          What's wrong? (QMake version 3.1 Using Qt version 5.10.1 in D:/Qt/5.10.1/msvc2015/lib in Windows 10)

          A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 26 Apr 2019, 04:13 last edited by
          #3

          @Limer please show the compile output

          Qt has to stay free or it will die.

          L 1 Reply Last reply 26 Apr 2019, 05:04
          0
          • D dheerendra
            26 Apr 2019, 02:15

            @Limer said in use a string defined macro in *.pro file:

            CURRENT_APP_VERSION

            You are doing the mistake in defined string. What you defined is CURRENT_VERSION. However printing the CURRENT_APP_VERSION.

            L Offline
            L Offline
            Limer
            wrote on 26 Apr 2019, 05:03 last edited by Limer
            #4

            @dheerendra Had updated this post.

            1 Reply Last reply
            0
            • A aha_1980
              26 Apr 2019, 04:13

              @Limer please show the compile output

              L Offline
              L Offline
              Limer
              wrote on 26 Apr 2019, 05:04 last edited by Limer
              #5

              @aha_1980

              D:\Test\src\main_window.cpp:32: error: C2065: “CURRENT_APP_VERSION”: 未声明的标识符
              
              J 1 Reply Last reply 26 Apr 2019, 05:13
              0
              • L Limer
                26 Apr 2019, 05:04

                @aha_1980

                D:\Test\src\main_window.cpp:32: error: C2065: “CURRENT_APP_VERSION”: 未声明的标识符
                
                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 26 Apr 2019, 05:13 last edited by
                #6

                @Limer Can you show the compiler call?

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

                L 1 Reply Last reply 26 Apr 2019, 06:57
                2
                • J jsulm
                  26 Apr 2019, 05:13

                  @Limer Can you show the compiler call?

                  L Offline
                  L Offline
                  Limer
                  wrote on 26 Apr 2019, 06:57 last edited by
                  #7

                  @jsulm Sorry, What's meaning of compiler call?

                  J 1 Reply Last reply 26 Apr 2019, 06:59
                  0
                  • L Limer
                    26 Apr 2019, 06:57

                    @jsulm Sorry, What's meaning of compiler call?

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 26 Apr 2019, 06:59 last edited by
                    #8

                    @Limer Go to "Compile Ouput" tab in QtCreator, copy the build log there and paste it here. What we want to see is which parameters are passed to the compiler when it is called.

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

                    L 1 Reply Last reply 26 Apr 2019, 07:04
                    1
                    • J jsulm
                      26 Apr 2019, 06:59

                      @Limer Go to "Compile Ouput" tab in QtCreator, copy the build log there and paste it here. What we want to see is which parameters are passed to the compiler when it is called.

                      L Offline
                      L Offline
                      Limer
                      wrote on 26 Apr 2019, 07:04 last edited by
                      #9

                      @jsulm 0_1556262284001_4E02986F-7219-42aa-9968-657E5BE10E9D.png

                      J 1 Reply Last reply 26 Apr 2019, 07:09
                      0
                      • L Limer
                        26 Apr 2019, 07:04

                        @jsulm 0_1556262284001_4E02986F-7219-42aa-9968-657E5BE10E9D.png

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 26 Apr 2019, 07:09 last edited by
                        #10

                        @Limer I don't see any of your APP_* defines being passed to the compiler.
                        Did you actually rerun qmake after changing pro file?

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

                        L 1 Reply Last reply 26 Apr 2019, 07:16
                        4
                        • J jsulm
                          26 Apr 2019, 07:09

                          @Limer I don't see any of your APP_* defines being passed to the compiler.
                          Did you actually rerun qmake after changing pro file?

                          L Offline
                          L Offline
                          Limer
                          wrote on 26 Apr 2019, 07:16 last edited by
                          #11

                          @jsulm Ohhhhhhhhhhhhhh, solve it. After I delete the build-HaiwellClient-Desktop_Qt_5_10_1_MSVC2015_32bit-Release
                          directory, rebuild project, it success. Thanks a lot for your patient response.

                          1 Reply Last reply
                          1

                          1/11

                          26 Apr 2019, 01:26

                          • Login

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