How to check if a library is installed?
To do this in a distro-independent* fashion you can use ldconfig with grep, like this:
ldconfig -p | grep libjpeg
If libjpeg is not installed, there will be no output. If it is installed, you will get a line for each version available.
Replace libjpeg by any library you want, and you have a generic, distro-independent* way of checking for library availability.
If for some reason the path to ldconfig is not set, you can try to invoke it using its full path, usually /sbin/ldconfig
.
**99% of the times*
You can check with the package manager of your distribution (aptitude, yum, ...) but as you did not give your distribution I can't give you the right command.
Another way can be to run gcc -ljpeg
, if you get 'ld: library not found for -ljpeg' it means that gcc has not found the library (but it don't mean that it's not installed), if you get something like 'Undefined symbols: "_main", referenced from: ...' it means that libjpeg has been found.
locate libjpeg; ls /usr/lib/libjpeg*; ls /lib/libjpeg*
are some other way to find if the lib in installed in the system
There is many other way to check that, if you give us more context (why you need to check if libjpeg is installed) we could give you the best solution for your specific case.