Linux find library package

How to check if a library is installed?

In Linux, how do I check if a library is installed or not? (from the command line of course). In my specific case now, I want to check whether libjpeg is installed.

10 Answers 10

To do this in a distro-independent* fashion you can use ldconfig with grep, like this:

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 .

Can you specify 99% times? bash: ldconfig: command not found on Debian x64 Jessie with xfce! This is the recomended debian release on the debian website.

@TomášZato: ldconfig is not available ( command not found shows up) if you try to run it without being superuser.

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 are many other ways 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.

Читайте также:  Выключить компьютер linux командная строка

I use the whereis utility.

l1feh4ck3r@xxx:~$ whereis libjpeg libjpeg: /usr/lib/libjpeg.so /usr/lib/libjpeg.a /usr/lib/libjpeg.la 

For deb-based distribution you can do

Or if you know the filename only, use

The filename is usually libsomething.so[.version].

I find dpkg -s limited in utility, because it wants the actual package name, which may differ subtly or significantly from the library itself. I use dpkg -s|grep LIBRARY

When the lib is installed, it yields:

undefined reference to 'main' 

When the lib is not installed:

On Redhat based systems, one can use pkg-config to verify if a library is installed or not. Many rpm binaries actually make the same checks before proceeding with installation, so we can reasonably rely on its veracity.

pkg-config --cflags jpeg pkg-config --libs jpeg pkg-config --cflags "jpeg >= 1.0.0" # for version check pkg-config --modversion jpeg | awk -F. '< printf "0x%02X%02X%02X\n",$1,$2,$3 >' #version check 

This is done by configuration tools on linux all the time.

Other tricks would use commands like ldconfig and dpkg .

On Ubuntu 20.04, I am able to display a wealth of relevant information for a package using aptitude.

% aptitude show libssl-dev Package: libssl-dev Version: 1.1.1f-1ubuntu2.1 State: installed Automatically installed: no Multi-Arch: same Priority: optional Section: libdevel Maintainer: Ubuntu Developers Architecture: amd64 Uncompressed Size: 8,006 k Depends: libssl1.1 (= 1.1.1f-1ubuntu2.1) Suggests: libssl-doc Conflicts: libssl1.0-dev Breaks: libssl-dev:i386 (!= 1.1.1f-1ubuntu2.1) Replaces: libssl-dev:i386 (< 1.1.1f-1ubuntu2.1) Description: Secure Sockets Layer toolkit - development files This package is part of the OpenSSL project's implementation of the SSL and TLS cryptographic protocols for secure communication over the Internet. It contains development libraries, header files, and manpages for libssl and libcrypto. Homepage: https://www.openssl.org/ 

To find which package would provide a particular file I have found apt-file very useful - some instructions are here: https://linuxhint.com/find_which_package_contains_specific_file_ubuntu/

% apt-file search 'libjpeg.so' darktable: /usr/lib/x86_64-linux-gnu/darktable/plugins/imageio/format/libjpeg.so libjpeg-turbo8: /usr/lib/x86_64-linux-gnu/libjpeg.so.8 libjpeg-turbo8: /usr/lib/x86_64-linux-gnu/libjpeg.so.8.2.2 libjpeg-turbo8-dev: /usr/lib/x86_64-linux-gnu/libjpeg.so libjpeg62: /usr/lib/x86_64-linux-gnu/libjpeg.so.62 libjpeg62: /usr/lib/x86_64-linux-gnu/libjpeg.so.62.0.0 libjpeg62-dev: /usr/lib/x86_64-linux-gnu/libjpeg.so libjpeg9: /usr/lib/x86_64-linux-gnu/libjpeg.so.9 libjpeg9: /usr/lib/x86_64-linux-gnu/libjpeg.so.9.4.0 libjpeg9-dev: /usr/lib/x86_64-linux-gnu/libjpeg.so libxine2-misc-plugins: /usr/lib/x86_64-linux-gnu/xine/plugins/2.7/xineplug_decode_libjpeg.so nsight-systems: /usr/lib/nsight-systems/Host-x86_64/libjpeg.so.8 

Источник

How to find location of installed library

Background: I'm trying to build my program but first I need to set up libraries in NetBeans. My project is using GLU and therefore I installed libglu-dev. I didn't note the location where the libraries were located and now I can't find them. I've switched to Linux just a few days ago and so far I'm very content with it, however I couldn't google this one out and became frustrated. Is there way to find out where files of package were installed without running the installation again? I mean if I got library xxx and installed it some time ago, is there some-command xxx that will print this info? I've already tried locate, find and whereis commands, but either I'm missing something or I just can't do it correctly. For libglu, locate returns:

/usr/share/bug/libglu1-mesa /usr/share/bug/libglu1-mesa/control /usr/share/bug/libglu1-mesa/script /usr/share/doc/libglu1-mesa /usr/share/doc/libglu1-mesa/changelog.Debian.gz /usr/share/doc/libglu1-mesa/copyright /usr/share/lintian/overrides/libglu1-mesa /var/lib/dpkg/info/libglu1-mesa:i386.list /var/lib/dpkg/info/libglu1-mesa:i386.md5sums /var/lib/dpkg/info/libglu1-mesa:i386.postinst /var/lib/dpkg/info/libglu1-mesa:i386.postrm /var/lib/dpkg/info/libglu1-mesa:i386.shlibs 

The other two commands fail to find anything. Now locate did its job, but I'm sure none of those paths is where the library actually resides (at least everything I was linking so far was in /usr/lib or /usr/local/lib ). libglu was introduced just as example. I'm looking for a general solution for this problem.

Читайте также:  Создать файл линукс терминал как

Источник

Where are package library and header files installed?

After downloading and installing a package in Ubuntu, how can I check where the library and header files were written to? I believe that this has something to do with the package's .pc file, but I do not know how to find that file either. For example, I have downloaded the PCL (Point Cloud Library) package, and then in a sample CMakeLists.txt file, I have been given the following:

include_directories($) link_directories($) add_definitions($) 

Where are these environment variables defined, and how can I see them? If I compiled the libraries from source rather than through a package, will this be any different? Will a .pc file be created automatically?

That just returns an empty line. However, compiling my project as above works fine so it must be using the PCL libraries. Is it searching anywhere else?

If you installed a debian package you can see the content via dpkg -L . If you install from source, it depends heavily on the source and you need to familiarise yourself with the build system it uses.

I had similar confusions. You can check to what values $ resolves to by using message command in your CMakeLists.txt i.e. add this line: message("$) or message("PCL_INCLUDE_DIRS = " $) . It will display the result when you run cmake .. Do the same for other macros/variables i.e. $ and $

2 Answers 2

If you install the package containing the libpcl development files

sudo apt-get install libpcl-dev 

You can list the installed files

an see the location of all headers.

. /usr/include/pcl-1.7/pcl/filters/fast_bilateral.h /usr/include/pcl-1.7/pcl/filters/voxel_grid_covariance.h /usr/include/pcl-1.7/pcl/filters/voxel_grid_occlusion_estimation.h /usr/include/pcl-1.7/pcl/filters/median_filter.h /usr/include/pcl-1.7/pcl/filters/crop_box.h /usr/include/pcl-1.7/pcl/filters/voxel_grid_label.h /usr/include/pcl-1.7/pcl/filters/covariance_sampling.h /usr/include/pcl-1.7/pcl/filters/random_sample.h /usr/include/pcl-1.7/pcl/filters/normal_refinement.h /usr/include/pcl-1.7/pcl/filters/project_inliers.h /usr/include/pcl-1.7/pcl/filters/fast_bilateral_omp.h /usr/include/pcl-1.7/pcl/filters/clipper3D.h /usr/include/pcl-1.7/pcl/filters/convolution.h /usr/include/pcl-1.7/pcl/filters/passthrough.h /usr/include/pcl-1.7/pcl/filters/conditional_removal.h /usr/include/pcl-1.7/pcl/filters/impl /usr/include/pcl-1.7/pcl/filters/impl/frustum_culling.hpp /usr/include/pcl-1.7/pcl/filters/impl/conditional_removal.hpp /usr/include/pcl-1.7/pcl/filters/impl/convolution_3d.hpp /usr/include/pcl-1.7/pcl/filters/impl/voxel_grid_covariance.hpp /usr/include/pcl-1.7/pcl/filters/impl/fast_bilateral_omp.hpp /usr/include/pcl-1.7/pcl/filters/impl/project_inliers.hpp /usr/include/pcl-1.7/pcl/filters/impl/morphological_filter.hpp /usr/include/pcl-1.7/pcl/filters/impl/crop_box.hpp /usr/include/pcl-1.7/pcl/filters/impl/covariance_sampling.hpp /usr/include/pcl-1.7/pcl/filters/impl/local_maximum.hpp /usr/include/pcl-1.7/pcl/filters/impl/plane_clipper3D.hpp /usr/include/pcl-1.7/pcl/filters/impl/bilateral.hpp /usr/include/pcl-1.7/pcl/filters/impl/voxel_grid_occlusion_estimation.hpp . 

Источник

Читайте также:  Microsoft surface rt линукс

How to get the list of installed library packages only?

I want to get the list of installed library packages only from terminal. Is there any command for that?

5 Answers 5

The -v option will show the libraries version.

267 libs found in cache `/etc/ld.so.cache' libz.so.1 (libc6) => /usr/lib/libz.so.1 libz.so (libc6) => /usr/lib/libz.so libxslt.so.1 (libc6) => /usr/lib/libxslt.so.1 libxml2.so.2 (libc6) => /usr/lib/libxml2.so.2 libxcb.so.1 (libc6) => /usr/lib/libxcb.so.1 libxcb-xlib.so.0 (libc6) => /usr/lib/libxcb-xlib.so.0 libwrap.so.0 (libc6) => /lib/libwrap.so.0 libvolume_id.so.0 (libc6) => /lib/libvolume_id.so.0 libuuid.so.1 (libc6) => /lib/libuuid.so.1 libutil.so.1 (libc6, hwcap: 0x8008000000008000, OS ABI: Linux 2.6.8) => /lib/tls/i686/cmov/libutil.so.1 libutil.so.1 (libc6, OS ABI: Linux 2.6.8) => /lib/libutil.so.1 libutil.so (libc6, OS ABI: Linux 2.6.8) => /usr/lib/libutil.so libusb-0.1.so.4 (libc6) => /lib/libusb-0.1.so.4 libusb-0.1.so.4 (libc6) => /usr/lib/libusb-0.1.so.4 libulockmgr.so.1 (libc6) => /lib/libulockmgr.so.1 libt1x.so.5 (libc6) => /usr/lib/libt1x.so.5 libt1.so.5 (libc6) => /usr/lib/libt1.so.5 libtiff.so.4 (libc6) => /usr/lib/libtiff.so.4 libticw.so.5 (libc6) => /lib/libticw.so.5 

If you want to turn that list into a list of packages, you can do something like this:

dpkg -S $(/sbin/ldconfig -p | awk 'NR>1 < print $NF >') 

And you can further massage that to cut out errors, unneeded components and duplicates:

$ dpkg -S $(/sbin/ldconfig -p | awk 'NR>1 < print $NF >') 2>/dev/null | sed 's/\: .*$//' | sort -u akregator ark binutils calligra-libs comerr-dev compiz-core dolphin e2fslibs:amd64 freeglut3:amd64 gettext . 

Источник

Оцените статью
Adblock
detector