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 Determine if installed Library ??
QtWS25 Last Chance

How to Determine if installed Library ??

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.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.
  • P Offline
    P Offline
    Pada_
    wrote on last edited by
    #1

    I am using Linux 64 Bit + Qt 5.4.

    Qt program tries to extract the zip or rar archive.

    In the Linux environment, a library package called unrar must be installed.

    Before unpacking, I want to check if the unrar library package is installed on the user's computer.

    Is there a function to find the library or a function to judge?

    jsulmJ 1 Reply Last reply
    0
    • P Pada_

      I am using Linux 64 Bit + Qt 5.4.

      Qt program tries to extract the zip or rar archive.

      In the Linux environment, a library package called unrar must be installed.

      Before unpacking, I want to check if the unrar library package is installed on the user's computer.

      Is there a function to find the library or a function to judge?

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

      @Pada_ Usually you link against the lib and it is loaded together with your app when it starts. Or do you want to load the lib dynamically?

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

      P 1 Reply Last reply
      1
      • jsulmJ jsulm

        @Pada_ Usually you link against the lib and it is loaded together with your app when it starts. Or do you want to load the lib dynamically?

        P Offline
        P Offline
        Pada_
        wrote on last edited by
        #3

        @jsulm

        Whenever I run a function called A, I want to know if the computer has a Linux package installed.

        jsulmJ 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Are you running the application using QProcess or are you using the library directly in your application ?
          In the first case, QProcess will return an error so you can use that in the second case, your application will not start because it can find the dependencies.

          Depending on how your distribute your package, you should already have whatever package you need as a dependency of your application so it triggers its installation when you install your package.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          P 1 Reply Last reply
          2
          • P Pada_

            @jsulm

            Whenever I run a function called A, I want to know if the computer has a Linux package installed.

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

            @Pada_ said in How to Determine if installed Library ??:

            I want to know if the computer has a Linux package installed

            Well, then take a look at apt-get, rpm and what else is there (there are many package managesr on Linux).
            But I still don't understand your use case/problem: if you want unpack a file in your app then simply link your app against a lib which supports that file format and then distribute that lib with your binaries.

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

            1 Reply Last reply
            1
            • SGaistS SGaist

              Hi,

              Are you running the application using QProcess or are you using the library directly in your application ?
              In the first case, QProcess will return an error so you can use that in the second case, your application will not start because it can find the dependencies.

              Depending on how your distribute your package, you should already have whatever package you need as a dependency of your application so it triggers its installation when you install your package.

              P Offline
              P Offline
              Pada_
              wrote on last edited by
              #6

              @jsulm
              @SGaist

              I am going to do the following to determine if there is UNRAR on Linux.

              1. Enter terminal UNRAR with QProcess and execute.

              2. Would you get an error message without UNRAR?

              3. Receive the QProcess result and do not execute it in case of error.

              Is the method above correct?

              JonBJ 1 Reply Last reply
              0
              • P Pada_

                @jsulm
                @SGaist

                I am going to do the following to determine if there is UNRAR on Linux.

                1. Enter terminal UNRAR with QProcess and execute.

                2. Would you get an error message without UNRAR?

                3. Receive the QProcess result and do not execute it in case of error.

                Is the method above correct?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @Pada_
                I don't know what you mean/intend with your use of the word "terminal" here. You don't want any terminal to be involved.

                There are several ways of testing for it. Here's a simple start:

                int result = QProcess::execute("unrar", []);
                if (result == -2)
                    qDebug() << "Could not start process";
                

                See https://doc.qt.io/qt-5/qprocess.html#execute for this example.

                Beware, Linux is case-sensitive, I doubt it would be UNRAR, more likely unrar....

                unrar is not installed under Ubuntu at least. apt install offers unrar-free & unrar packages.

                1 Reply Last reply
                3

                • Login

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