Libraries

如何在 GNU/Linux 中使用通過包管理器安裝的庫

  • December 15, 2018

lzma-dev我使用包管理器(例如apt-getfor Debianor )安裝了一個庫(例如Ubuntu)。我該如何使用它?我在哪裡可以找到libsheaderssos(動態庫)怎麼樣?

假設該軟體包已經安裝,您可以使用dpkg -L, for list 查看它的內容。

例子

$ 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

被命名<something>-dev的包通常只是 C 標頭檔(.h文件),這個包有點不尋常,因為它包含(.c.h文件)。順便說一下,這是 LZMA 庫的實際來源。

如果你想要 LZMA 庫的.so文件和.h文件,那麼你可以針對它進行編譯,你需要安裝“liblzma-dev”包。

例子

這是標頭檔。

$ 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

以及實際的.so庫:

$ 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

引用自:https://unix.stackexchange.com/questions/114999