Compiling and Installing software from source in Linux

By: Jason Lambert Emailed: 1645 times Printed: 2119 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

Some software is distributed in "Source form". This means you download a file containing all the source code for the application you want to install, unpack it, and compile it on your system. Compiling is the process of turning the source code into an executable binary. The common myth and newbie assumption is that this is very hard todo, or it is only for programmers. Wrong. It is a fairly straight forward process, and you will find that a lot of software you install will need to be built from source.

Typically applications you must compile from source will come as a ".tar.gz", ".tar.bz2", or ".zip" file.

For organisational purposes, I like to save my source zip file to /usr/local/src/, but this is totally up to you. For the rest of this section we will assume you have downloaded your zip file to /usr/local/src/. If you do not have a /usr/local/src directory, you can create it with the following "mkdir" (make directory) command:

mkdir /usr/local/src/
So, we have our source package in /usr/local/src/.

Change to the /usr/local/src/ directory with the "cd" (change directory) command like so:

cd /usr/local/src/
Use the "ls" (list directory contents) command, to see the file is present:

ls

We now need to unzip the zipped file, this is done differently depending on the file extension.

for files ending in .tar.gz, use:
tar -zxvf <filename>
(replacing <filename> with the name of the file).

for files ending in .tar.bz2, use:
bunzip2 <filename>
for files ending in .zip, use:
unzip <filename> You should now have a new directory, containing all of the source files. To confirm it exists, and to get its name, use the "ls" command again.
ls
we now need to go into the new directory, so use the cd command:
cd <directory>
This is where things will differ. Some packages will have an INSTALL or README file which will contain installation instructions. use "ls" to see if the software has an install or readme file. If it does have one, you can use the "more" command to read it, like so:
more INSTALL
Generally, the final 3 stages are as follows:
- Configure the installation
- Compile the software
- Install the binaries

The pre-installation configuration is done by executing ./configure:
./configure
This will perform some requirements testing on your system, and create a "Makefile" which will explain to the "make" utility how the software should be compiled. If you receive any error messages during this stage, you may wish to search the forums to see if they have been found and resolved by someone else already, if not, feel free to post a question on the forums - Please include all of the output including any error messages, and some details about your system - what distro you are using, what are you trying to install etc etc

The next stage is to compile the software, this is done using "make". When you run "make" it will read the instructions in the Makefile and build the application binaries.
make

The final stage is to install these binaries, ie, copy them to a more permanent location. Typically only the "root" user can do this, so you will need to swich to the root user with the "su" command:
su
Once you are root, install the binaries using the "make" command, followed by "install", like so:
make install
That is it!. Check the user documentation of the software you installed for details of how to run the application.

Remember that if you have any problems, please post in the most relevant section of the forums. - When posting, remember to include as much info as possible, including all output and error messages.


Linux Home | All Linux Tutorials | Latest Linux Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Jason Lambert
Installing using Debian apt-get in Linux
Installing RPM's using the Redhat Package Manager in Linux
Compiling and Installing software from source in Linux

More Tutorials in Linux
smskannel SMS gateway run in background
Running jar files in background in ssh window
Could not open '': No such file or directory at lib/ExtUtils/MM_Unix.pm line 2697
Can't locate ExtUtils/MakeMaker.pm in @INC ...
bash: make: command not found
apxs: command not found
bash: svn: command not found
make: Nothing to be done for `all'.
How to burn your CD / DVD ISO image using Media Creator (Adaptec/Roxio) on Windows
How to burn your CD / DVD ISO image using Nero Burning ROM (Ahead Software) on Windows
How to burn your CD / DVD ISO image using Nero Express (Ahead Software) on Windows
How to burn your CD / DVD ISO image using NISO Recorder V2 Power Toy on Windows
How to burn your CD / DVD ISO image using k3b on CentOS
Compiling and Installing software from source in Linux
Installing RPM's using the Redhat Package Manager in Linux

More Latest News
Most Viewed Articles (in Linux )
Nested if-else-fi in Linux Shell Script
Nested for loop in Linux Shell Script
sum of all digits in a given number using Shell Script
for loop in Linux Shell Script
Calculator tutorial in Shell Script
test command or [ expr ] in Linux Shell Script
Check for leap year in Shell Script
Command line arguments in Shell Script
Find the biggest number in Shell Script
Menu based programs in Shell Script
Compiling and Installing software from source in Linux
bash: svn: command not found
Variables in Linux Shell Script
How to define User defined variables in Linux Shell Script
read Statement in Linux Shell Script
Most Emailed Articles (in Linux)
bash: make: command not found
smskannel SMS gateway run in background
Input - Output redirection in Linux Shell Script
sum of all digits in a given number using Shell Script
How to burn your CD / DVD ISO image using NISO Recorder V2 Power Toy on Windows
How to use Linux?
getopts tutorial in Shell Script
How to burn your CD / DVD ISO image using Nero Express (Ahead Software) on Windows
How to burn your CD / DVD ISO image using k3b on CentOS
bash: svn: command not found
Could not open '': No such file or directory at lib/ExtUtils/MM_Unix.pm line 2697
Mounting cdrom in cent os 5 linux
Download Linux. Which linux and where?
case..esac..in Linux Shell Script
Print contents of a file using Shell Script