76

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.

karel
  • 122,695
  • 134
  • 305
  • 337
Raven
  • 874

2 Answers2

110

Easy! dpkg -L packagename. That will list all files (with location) that were brought in by the package.

  • 3
    Wow, exactly what I was looking for, thanks! Just a quick note: the one I was looking for is /usr/lib/i386-linux-gnu/libGLU.so.1 (obtained with dpkg) and the actual name of library for the command is libglu1-mesa. – Raven Mar 23 '12 at 21:50
  • 3
    Great. I'll also recommend apt-file. It needs to be installed and then you need to do apt-file update. apt-file list does the same as dpkg -L, but without the need to install the package first. apt-file search enables you to find out which package provides a certain file. Cool tools :) – Jo-Erlend Schinstad Mar 23 '12 at 21:56
  • 2
    It's complementary but ldd can list the libraries used by a binary and where the system will find them. – Sandburg Aug 04 '22 at 12:27
  • Thanks! Location of php-curl in Ubuntu 22.04 LTS : # dpkg -L php8.3-curl followed by less /etc/php/8.3/cli/conf.d/20-curl.ini. To find the libraries used by php-curl I used this: ldd /usr/lib/php/20230831/curl.so. It seems that libcurl can use both GNUTLS and OpenSSL ciphers. To figure out which cipher (GNUTLS or OpenSSL) was used in a given call, I'm going to try this: https://stackoverflow.com/a/3760294/5685406 – site80443 Aug 22 '24 at 11:39
15

In case if you are not sure about package name you could list all packages and try to find requested:

dpkg --get-selections | grep -v deinstall | grep <packagename>

For example:

$ dpkg --get-selections | grep -v deinstall | grep zip

Output:

bzip2 install
gzipinstall
p7zip-fullinstall
unzipinstall                                                                       
zipinstall  

And then:

$ dpkg -L zip

Output:

/.  
/usr
/usr/share
/usr/share/doc
/usr/share/doc/zip
/usr/share/doc/zip/copyright
/usr/share/doc/zip/TODO
/usr/share/doc/zip/changelog.Debian.gz
/usr/share/doc/zip/WHATSNEW
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/zipsplit.1.gz
/usr/share/man/man1/zipcloak.1.gz
/usr/share/man/man1/zip.1.gz
/usr/share/man/man1/zipnote.1.gz
/usr/bin
/usr/bin/zipsplit
/usr/bin/zipcloak
/usr/bin/zip
/usr/bin/
/usr/share/doc/zip/changelog.gz
Blub
  • 105