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. How to add macro for the LIBS in the .PRO file
Forum Updated to NodeBB v4.3 + New Features

How to add macro for the LIBS in the .PRO file

Scheduled Pinned Locked Moved Unsolved General and Desktop
31 Posts 3 Posters 8.0k 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.
  • Cobra91151C Cobra91151

    @ManiRon

    @ManiRon said in How to add macro for the LIBS in the .PRO file:

    @Cobra91151 Sir i am trying to add

    uinx{
    LIBS+= -L$$PWD/.../lib/linus/-lData
    LIBS+= -L$$PWD/.../lib/Xenomai/-lData1 -lrtdm -lrt -lxenomai
    }

    I am adding the linux and xenomai library and trying to compile . but it throws error. As it detects the linux library and it couldnt find the xenomai library it throws error.
    My question is i want to define all my library and based on the platform or OS i am running it should detect its particular library.
    For example : linux, xenomai, windiows. These are the platforms i am running the application. Why i ask this is because every time i have to add the corresponding library and compile it and the run the application . So is there any solution for this?

    First all of all, you typed uinx, it should be unix, so the errors might be with it. Secondly, Xenomai is built with the Linux kernel, so in your case it will load both libs.

    So, you have to be more specific with your checks, read my post above:
    In addition to the win32, macx, and unix values used in many scope conditions, various other built-in platform and compiler-specific values...

    ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by ManiRon
    #11

    @Cobra91151

    for xenomai what should i do sir?

    While giving unix it runs the library for linux and if i want to do the same for xenomai what should i specify?

    And i want to know where this message($$QMAKESPEC) will be displayed?

    Cobra91151C 1 Reply Last reply
    0
    • ManiRonM ManiRon

      @Cobra91151

      for xenomai what should i do sir?

      While giving unix it runs the library for linux and if i want to do the same for xenomai what should i specify?

      And i want to know where this message($$QMAKESPEC) will be displayed?

      Cobra91151C Offline
      Cobra91151C Offline
      Cobra91151
      wrote on last edited by Cobra91151
      #12

      @ManiRon

      Xenomai should have something, I use Windows OS, so I don't know exactly. message($$QMAKESPEC) will be displayed in the General Messages in the Qt Creator. Check the output message($$QMAKESPEC) and reply. I will try to help you.

      ManiRonM 1 Reply Last reply
      2
      • Cobra91151C Cobra91151

        @ManiRon

        Xenomai should have something, I use Windows OS, so I don't know exactly. message($$QMAKESPEC) will be displayed in the General Messages in the Qt Creator. Check the output message($$QMAKESPEC) and reply. I will try to help you.

        ManiRonM Offline
        ManiRonM Offline
        ManiRon
        wrote on last edited by
        #13

        @Cobra91151 Ok sir

        ManiRonM 1 Reply Last reply
        0
        • ManiRonM ManiRon

          @Cobra91151 Ok sir

          ManiRonM Offline
          ManiRonM Offline
          ManiRon
          wrote on last edited by
          #14

          @ManiRon
          I tried with windows it returned win32-g++ ?

          Cobra91151C 1 Reply Last reply
          0
          • ManiRonM ManiRon

            @ManiRon
            I tried with windows it returned win32-g++ ?

            Cobra91151C Offline
            Cobra91151C Offline
            Cobra91151
            wrote on last edited by
            #15

            @ManiRon said in How to add macro for the LIBS in the .PRO file:

            @ManiRon
            I tried with windows it returned win32-g++ ?

            Ok. So you can use it on Windows, but you have to check it with Xenomai. By the way, win32-g++ means that you use MinGW compiler. Reply when you get the output for Xenomai.

            ManiRonM 3 Replies Last reply
            0
            • Cobra91151C Cobra91151

              @ManiRon said in How to add macro for the LIBS in the .PRO file:

              @ManiRon
              I tried with windows it returned win32-g++ ?

              Ok. So you can use it on Windows, but you have to check it with Xenomai. By the way, win32-g++ means that you use MinGW compiler. Reply when you get the output for Xenomai.

              ManiRonM Offline
              ManiRonM Offline
              ManiRon
              wrote on last edited by
              #16

              @Cobra91151 ok Sir

              1 Reply Last reply
              0
              • Cobra91151C Cobra91151

                @ManiRon said in How to add macro for the LIBS in the .PRO file:

                @ManiRon
                I tried with windows it returned win32-g++ ?

                Ok. So you can use it on Windows, but you have to check it with Xenomai. By the way, win32-g++ means that you use MinGW compiler. Reply when you get the output for Xenomai.

                ManiRonM Offline
                ManiRonM Offline
                ManiRon
                wrote on last edited by
                #17

                @Cobra91151

                I have a doubt?

                Cobra91151C 1 Reply Last reply
                0
                • Cobra91151C Cobra91151

                  @ManiRon said in How to add macro for the LIBS in the .PRO file:

                  @ManiRon
                  I tried with windows it returned win32-g++ ?

                  Ok. So you can use it on Windows, but you have to check it with Xenomai. By the way, win32-g++ means that you use MinGW compiler. Reply when you get the output for Xenomai.

                  ManiRonM Offline
                  ManiRonM Offline
                  ManiRon
                  wrote on last edited by
                  #18

                  @Cobra91151

                  i generated a code in .pro file as

                  win32-g++{
                  LIBS += path
                  }
                  linux-g++ {
                  LIBS += path
                  }

                  i am creating a bundle with the .exe and the required files and if i run this in a PC which does not have QT will it work

                  Cobra91151C 1 Reply Last reply
                  0
                  • ManiRonM ManiRon

                    @Cobra91151

                    I have a doubt?

                    Cobra91151C Offline
                    Cobra91151C Offline
                    Cobra91151
                    wrote on last edited by Cobra91151
                    #19

                    @ManiRon said in How to add macro for the LIBS in the .PRO file:

                    @Cobra91151

                    I have a doubt?

                    @ManiRon said in How to add macro for the LIBS in the .PRO file:

                    @Cobra91151

                    i generated a code in .pro file as

                    win32-g++{
                    LIBS += path
                    }
                    linux-g++ {
                    LIBS += path
                    }

                    i am creating a bundle with the .exe and the required files and if i run this in a PC which does not have QT will it work

                    You have doubt about what? Is linux-g++ scope condition from Xenomai output?

                    Also, you have to provide all the necessary Qt libs if the Qt is not static (on the PC which does not have Qt) otherwise it wont work. For example, for Windows, you have to run windeployqt.exe to get Qt shared libs.

                    Official docs about the deployment for Windows: http://doc.qt.io/qt-5/windows-deployment.html

                    ManiRonM 1 Reply Last reply
                    0
                    • ManiRonM ManiRon

                      @Cobra91151

                      i generated a code in .pro file as

                      win32-g++{
                      LIBS += path
                      }
                      linux-g++ {
                      LIBS += path
                      }

                      i am creating a bundle with the .exe and the required files and if i run this in a PC which does not have QT will it work

                      Cobra91151C Offline
                      Cobra91151C Offline
                      Cobra91151
                      wrote on last edited by Cobra91151
                      #20

                      @ManiRon

                      So, you should have something like this in the pro file:

                      TARGET = TestApp #Your executable filename without the extension
                      
                      win32-g++ {
                          LIBS += path
                          QMAKE_POST_LINK = $$(QTDIR)/bin/windeployqt.exe $$shell_quote($$DESTDIR/$$shell_quote($$TARGET).exe) --no-compiler-runtime
                      }
                      

                      This will add one more build step to the project, but it will help to deploy all the necessary Qt libs. By the way, it will work only for Windows deployment and shared libs Qt version.

                      Linux deployment Qt docs here: http://doc.qt.io/qt-5/linux-deployment.html

                      1 Reply Last reply
                      0
                      • Cobra91151C Cobra91151

                        @ManiRon said in How to add macro for the LIBS in the .PRO file:

                        @Cobra91151

                        I have a doubt?

                        @ManiRon said in How to add macro for the LIBS in the .PRO file:

                        @Cobra91151

                        i generated a code in .pro file as

                        win32-g++{
                        LIBS += path
                        }
                        linux-g++ {
                        LIBS += path
                        }

                        i am creating a bundle with the .exe and the required files and if i run this in a PC which does not have QT will it work

                        You have doubt about what? Is linux-g++ scope condition from Xenomai output?

                        Also, you have to provide all the necessary Qt libs if the Qt is not static (on the PC which does not have Qt) otherwise it wont work. For example, for Windows, you have to run windeployqt.exe to get Qt shared libs.

                        Official docs about the deployment for Windows: http://doc.qt.io/qt-5/windows-deployment.html

                        ManiRonM Offline
                        ManiRonM Offline
                        ManiRon
                        wrote on last edited by
                        #21

                        @Cobra91151

                        I tried for Xenomai OS but the message($$QMAKESPEC) is not printing at . Donno why ? and i am struck

                        Cobra91151C 1 Reply Last reply
                        0
                        • ManiRonM ManiRon

                          @Cobra91151

                          I tried for Xenomai OS but the message($$QMAKESPEC) is not printing at . Donno why ? and i am struck

                          Cobra91151C Offline
                          Cobra91151C Offline
                          Cobra91151
                          wrote on last edited by Cobra91151
                          #22

                          @ManiRon said in How to add macro for the LIBS in the .PRO file:

                          @Cobra91151

                          I tried for Xenomai OS but the message($$QMAKESPEC) is not printing at . Donno why ? and i am struck

                          Hi! What Qt version do you use on Xenomai? The problem might be because it can't find the compiler.

                          ManiRonM 1 Reply Last reply
                          0
                          • Cobra91151C Cobra91151

                            @ManiRon said in How to add macro for the LIBS in the .PRO file:

                            @Cobra91151

                            I tried for Xenomai OS but the message($$QMAKESPEC) is not printing at . Donno why ? and i am struck

                            Hi! What Qt version do you use on Xenomai? The problem might be because it can't find the compiler.

                            ManiRonM Offline
                            ManiRonM Offline
                            ManiRon
                            wrote on last edited by
                            #23

                            @Cobra91151 using 4.7 version QT in xenomai

                            Cobra91151C 1 Reply Last reply
                            0
                            • ManiRonM ManiRon

                              @Cobra91151 using 4.7 version QT in xenomai

                              Cobra91151C Offline
                              Cobra91151C Offline
                              Cobra91151
                              wrote on last edited by
                              #24

                              @ManiRon

                              So, for example you should check the directory: ...\Qt\4.7\mingw53_32\mkspecs

                              Here is what I get:

                              0_1536659785437_2018-09-11_125552.png

                              Xenomai is built with the Linux kernel, so you should try all the possible scope conditions for linux. Also, what compiler do you use on Xenomai? It will help to find it faster.

                              ManiRonM 1 Reply Last reply
                              0
                              • Cobra91151C Cobra91151

                                @ManiRon

                                So, for example you should check the directory: ...\Qt\4.7\mingw53_32\mkspecs

                                Here is what I get:

                                0_1536659785437_2018-09-11_125552.png

                                Xenomai is built with the Linux kernel, so you should try all the possible scope conditions for linux. Also, what compiler do you use on Xenomai? It will help to find it faster.

                                ManiRonM Offline
                                ManiRonM Offline
                                ManiRon
                                wrote on last edited by
                                #25

                                @Cobra91151

                                how to check the compiler sir?

                                Cobra91151C 1 Reply Last reply
                                0
                                • ManiRonM ManiRon

                                  @Cobra91151

                                  how to check the compiler sir?

                                  Cobra91151C Offline
                                  Cobra91151C Offline
                                  Cobra91151
                                  wrote on last edited by Cobra91151
                                  #26

                                  @ManiRon

                                  You can check the compiler: Tools => Options => Kits => Compilers in the Qt Creator.

                                  For example:

                                  0_1536662758977_2018-09-11_134420.png

                                  Are you sure you can build the empty project on Xenomai?

                                  ManiRonM 1 Reply Last reply
                                  0
                                  • Cobra91151C Cobra91151

                                    @ManiRon

                                    You can check the compiler: Tools => Options => Kits => Compilers in the Qt Creator.

                                    For example:

                                    0_1536662758977_2018-09-11_134420.png

                                    Are you sure you can build the empty project on Xenomai?

                                    ManiRonM Offline
                                    ManiRonM Offline
                                    ManiRon
                                    wrote on last edited by
                                    #27

                                    @Cobra91151

                                    Will check and say sir

                                    Cobra91151C 1 Reply Last reply
                                    0
                                    • ManiRonM ManiRon

                                      @Cobra91151

                                      Will check and say sir

                                      Cobra91151C Offline
                                      Cobra91151C Offline
                                      Cobra91151
                                      wrote on last edited by Cobra91151
                                      #28

                                      @ManiRon

                                      OK. By the way, I have another solution to your problem but I can't check it because older Qt -> Q_WS* macros were dropped in favour of Q_OS*. So I will add both solutions for older and newer Qt versions.

                                      You can add macros in the code to check the OS and load libs for example on Win OS:

                                      Qt 5.x:

                                      #ifdef Q_OS_WIN
                                      #pragma comment(lib, "yourlibforwin")
                                      #elif Q_OS_LINUX
                                      #pragma comment(lib, "yourlibforlinux")
                                      #else
                                      #pragma comment(lib, "yourlibforxenomai")
                                      #endif
                                      

                                      Docs: http://doc.qt.io/qt-5/qtglobal.html

                                      Qt 4.x

                                      #ifdef Q_WS_WIN
                                      #pragma comment(lib, "yourlibforwin")
                                      #else
                                      #pragma comment(lib, "yourlibforlinux")
                                      #endif
                                      

                                      Docs: http://doc.qt.io/archives/qt-4.8/qtglobal.html

                                      ManiRonM 1 Reply Last reply
                                      0
                                      • Cobra91151C Cobra91151

                                        @ManiRon

                                        OK. By the way, I have another solution to your problem but I can't check it because older Qt -> Q_WS* macros were dropped in favour of Q_OS*. So I will add both solutions for older and newer Qt versions.

                                        You can add macros in the code to check the OS and load libs for example on Win OS:

                                        Qt 5.x:

                                        #ifdef Q_OS_WIN
                                        #pragma comment(lib, "yourlibforwin")
                                        #elif Q_OS_LINUX
                                        #pragma comment(lib, "yourlibforlinux")
                                        #else
                                        #pragma comment(lib, "yourlibforxenomai")
                                        #endif
                                        

                                        Docs: http://doc.qt.io/qt-5/qtglobal.html

                                        Qt 4.x

                                        #ifdef Q_WS_WIN
                                        #pragma comment(lib, "yourlibforwin")
                                        #else
                                        #pragma comment(lib, "yourlibforlinux")
                                        #endif
                                        

                                        Docs: http://doc.qt.io/archives/qt-4.8/qtglobal.html

                                        ManiRonM Offline
                                        ManiRonM Offline
                                        ManiRon
                                        wrote on last edited by
                                        #29

                                        @Cobra91151 said in How to add macro for the LIBS in the .PRO file:

                                        comment

                                        can i implement this in the .PRO file?

                                        Cobra91151C 1 Reply Last reply
                                        0
                                        • ManiRonM ManiRon

                                          @Cobra91151 said in How to add macro for the LIBS in the .PRO file:

                                          comment

                                          can i implement this in the .PRO file?

                                          Cobra91151C Offline
                                          Cobra91151C Offline
                                          Cobra91151
                                          wrote on last edited by Cobra91151
                                          #30

                                          @ManiRon

                                          No, you can't have it in the .pro file. So what about the compiler? Have you built the empty project on Xenomai?

                                          ManiRonM 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