Read this till the end before actually trying out the steps.
After downloading the tar.gz file, untar it by running
tar -xvzf filename.tar.gz
After untarring it, the best way is to go through the README.txt or INSTALL.txt which can be found under the /docs directory among the untarred files.
However, assuming that the software you’re about to install are built with GNU’s autoconf and make tools, I’ll explain the steps below. (Meaning, in most of the cases the following steps will work.)
1. Check to see of there is a script called ‘configure’ among the untarred files. If yes skip this step. Otherwise, do
2. This will generate the configure script for you and you will be able to find it among the files. Once ‘configure’ is there, run
This will generate a file called the Makefile for you. However (A BIG HOWEVER), a Makefile will only be generated provided you have all the dependencies installed on your system. That is, the software you are about to install may depend on other software or libraries to work. Step 2 checks if these dependencies are met and will return an error if any of the dependencies are not met. When you see the error, you will have to install that software/library package in order for the configure script to execute succesfully. If you are using Ubuntu/Debian based distors, you just have to apt-get install the softwares.
3. After installing the dependencies and the successful completion of the configure script, a Makefile will be there among the files. Run
This will compile the files of the software. (Note: If you are making any changes to the software, make recognizes that change and recompiles only that. It thus saves you a lot of time by not recompiling the entire thing once again.
4. After the successful completion of make, run
sudo make install
This will install your softwares binary files and libraries under /usr/local.
5. You are good to go. Just type the name of the software in the terminal and hit enter.
IMPORTANT: The problem with the above approach is that (assuming you are using Debian/Ubuntu based distros) your package manager ‘apt’ doesn’t know that the software has been installed. As such, it might cause trouble if you use apt to install this software itself from the repository. The recommended way to install softwares from source is to install them into a non standard location. The changes you will have to do in the above steps in order to install the software into a non-standard location are explained below.
1. Same step.
2. Create a folder ‘temp’ (any name you want) somewhere in your home directory. For sake of explanation, I created a folder named ‘temp’ in my home folder. So its path will be /home/haris/temp. Now run
3. Same step.
4. You ran this step with sudo earlier because /usr/local was a standard location and you needed administrative privileges in order to install binary/library files there. But now, since we have given a non-standard location, just run
This will install the binary files of your software (the files that is to be executed in order to launch the program) in the specified location. In this case, under /home/haris/temp/bin.
5. You’re not good to go. In order to run the program, you need to go into the directory containing the binary files and run it from there by typing the name of the software. (This is because linux searches for the executables in standard locations such as /bin, /usr/bin, etc.) However, if you want the software to run from the prompt no matter in which directory you are, here is way for that.
6. The locations linux will search for the executables will be given in a variable called PATH. Try
in your terminal and you can see the locations.
7. What we need to do is to add the path of our installed software to the PATH variable. To do this, open up the file named .bashrc from your home folder.
sudo gedit ~/.bashrc
8. Add the following to the end of that file (in your case, give the path of the ‘bin’ folder of the installed software). In my case,
9. Save and exit. Restart your terminal and try typing the name of the software from anywhere you want. It will launch.
NOTE: Sometimes the Makefile will be there by default among the untarred files. In that case just do step 2 and 3.
Now, in order to uninstall the program, all you have to do is run
sudo make uninstall or make uninstall
depending on how you installed it. Run this command from wherever you ran the make command earlier.
Also, in order to clear the files created by make, run
That would be all. Thanks to Ershad!