How to Determine if installed Library ??
-
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?
-
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?
-
@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?
-
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.
-
Whenever I run a function called A, I want to know if the computer has a Linux package installed.
@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. -
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.
-
@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 likelyunrar
....unrar
is not installed under Ubuntu at least.apt install
offersunrar-free
&unrar
packages.