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?
Asked
Active
Viewed 1.1k times
1

Eric Carvalho
- 54,385

hellodear
- 4,673
1 Answers
3
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.

moosambi2020
- 308
-
what is the difference if I will put the files in usr/local and /usr/lib and /usr/include? I am new to ubuntu. Elaborate this thing. Thanks. – hellodear Jul 25 '14 at 05:07
-
/usr/lib
is the path for compiled libraries, whereas/usr/include
is the path where the C/C++ header files are stored which contain function prototypes to access the libraries. As already explained, there is no harm if you install the custom library in/usr/lib
or/usr/local
, either should work. For custom libraries,/usr/local
path is recommended only from administration perspective. Hope am clear. – moosambi2020 Jul 25 '14 at 12:53
/usr/include
contains the headers for the library, which you need if you wanted to write a program/library that uses this library and is only used during compilation, and that/usr/lib
contains the library itself, which is needed to run something that uses that library. Also, note that some buildsystems install into the/usr/local
prefix (which I prefer) instead of the/usr
prefix. – saiarcot895 Jul 24 '14 at 13:53