Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I hope this is not a very stupid question as I am very new to development in GNU/Linux.

I installed a library(for example lzma-dev) using a package manager(for example apt-get for Debian or Ubuntu). How can I use it? Where can I find the libs and headers? How about sos(dynamic libraries)?

share|improve this question
1  
Essentially, any properly set-up distro will ensure that libraries installed via its package manager can be found in directories that are in the compiler's default search path. (Assuming that the compiler was likewise installed via the package manager) –  Shadur Feb 13 at 13:40
    
@Shadur this means I can just #include <header.h>(for example for c++ libraries) and use it right along without having to think about adding library and include paths to the porject file, right? –  Jason Swartz Feb 13 at 14:18
1  
In most cases, yes, although from the looks of @slm's the files will be at /usr/include/<libname> so the include directive you'll likely need would be #include <libname/header.h> –  Shadur Feb 13 at 14:37

2 Answers 2

up vote 3 down vote accepted

Assuming the package has already been installed you can see the contents of it using dpkg -L, for list.

Example

$ dpkg -L lzma-dev
/.
/usr
/usr/include
/usr/include/lzma
/usr/include/lzma/LzHash.h
/usr/include/lzma/Types.h
/usr/include/lzma/LzmaEnc.h
/usr/include/lzma/LzFind.c
/usr/include/lzma/LzmaEnc.c
/usr/include/lzma/LzFind.h
/usr/include/lzma/LzmaDec.h
/usr/include/lzma/7zVersion.h
/usr/include/lzma/LzmaDec.c
/usr/share
/usr/share/doc
/usr/share/doc/lzma-dev
/usr/share/doc/lzma-dev/lzma.txt.gz
/usr/share/doc/lzma-dev/Methods.txt
/usr/share/doc/lzma-dev/7zC.txt.gz
/usr/share/doc/lzma-dev/changelog.Debian.gz
/usr/share/doc/lzma-dev/7zFormat.txt.gz
/usr/share/doc/lzma-dev/copyright

Packages that are named <something>-dev are typically just the C header files (.h files), this package is a bit unusual in that it includes (.c and .h files). Incidentally this is the actual source for the LZMA library.

If you want the .so files and the .h files for the LZMA library, so you can compile against it, you'll need to install the 'liblzma-dev` package.

Example

Here's the header files.

$ dpkg -L liblzma-dev | tail -15
/usr/include/lzma/version.h
/usr/include/lzma/hardware.h
/usr/include/lzma/index.h
/usr/include/lzma/index_hash.h
/usr/include/lzma/block.h
/usr/include/lzma/delta.h
/usr/include/lzma/check.h
/usr/include/lzma/filter.h
/usr/include/lzma/bcj.h
/usr/include/lzma/base.h
/usr/share/doc/liblzma-dev/NEWS.gz
/usr/share/doc/liblzma-dev/AUTHORS
/usr/share/doc/liblzma-dev/changelog.Debian.gz
/usr/share/doc/liblzma-dev/THANKS
/usr/lib/x86_64-linux-gnu/liblzma.so

As well as the actual .so library:

$ dpkg -L liblzma5 | tail -4
/lib
/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu/liblzma.so.5.0.0
/lib/x86_64-linux-gnu/liblzma.so.5
share|improve this answer
    
"and the .c and .h files for the LZMA library". The .c files are not packaged. They're source. Also, .so files are not part of a dev library, which just contain header files. The /usr/lib/x86_64-linux-gnu/liblzma.so here is a symbolic link. It points to a file in the library package liblzma5. –  Faheem Mitha Feb 13 at 18:31
    
@FaheemMitha - take a look at the contents of lzma-dev, it does contain .c files. –  slm Feb 13 at 18:39
    
@FaheemMitha - cleaned it up but this is a bit of a confusing example. –  slm Feb 13 at 18:45
    
@FaheemMitha - 12.10, lzma-dev: 9.22-2ubuntu2 –  slm Feb 13 at 22:50
dpkg -L lzma-dev

list all the files installed with apt-get for lzma-dev

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.