I want to include some libraries in my project like json-glib, beecrypt or libffi.
Usually, I install all the libraries using sudo apt-get install XYZ
.
But sometimes, I get a .tar
file of any library which I extract at some place on my desktop.
I don't know how to install these type of libraries for which I have the source code. I get the installed files in /usr/include
or sometimes in /usr/lib
folder when I install using the above command written.
How to do it in case of source code?
The recommended way to install a library which was downloaded in its source code form is:
Assuming you are in the home folder, extract the .tar, .tar.gz, .tar.bz2, .tar.xz file using,
tar xf source_filename
Go to the folder /home/some_user/libxxx/ (the folder into which the previous tar command extracted the files)
Run,
./configure --prefix=/usr/local
make
sudo make install
This installs the library in '/usr/local' which is the recommended path according to the convention when you are not installing a software via any package manager. Also, this will not pollute the existing libraries in '/usr/lib' which makes maintenance easy in case you wish to uninstall the library in future.