How to Install Software on Linux Compiling From Source
Two days back while configuring and fine tuning Fedora 15 on my machine, I tried to install one of my favorite plugins in GIMP namely “Save for Web” plugin. To my dismay though, there was no complied version for Fedora. So I had to download the source code of the plugin, compile, and install it.
The following are the steps needed to compile from source and install software on Linux.
Step 1: Install the necessary compiler tools
To compile software from source, you need to have three things. They are GCC compiler, intltool, and the development libraries of the software you wish to compile.
I installed the necessary tools using the following command :
$ su -c 'yum install gcc intltool'
Step 2: Download the source code of the software you wish to compile
Usually it will be in the form of a tar.gz or tar.bz compressed file format.
Unpack it into your current directory (home directory). If you are in GUI, you can use an archive manager. Alternately, in a terminal you use the following command depending on the type of archive.
tar -xvzf packagename.tar.gz
tar -xvjf packagename.tar.bz
This will unpack it into a directory called
packagename is a generic name I have given to explain the process. While you are executing the commands listed here, replace
packagename with the name of the package you have downloaded.
Step 3: Configuring the source
Open a terminal, move into the
packagename directory and run the following command.
This will run a series of tests to see if you have the necessary tools. If all goes well, it will exit without any errors.
If the configure script gives errors, it means you have to install something to satisfy its parameters (An explanation is given further below).
If there are errors, take appropriate action and re-run the ./configure script until it finishes executing successfully.
Step 4: Compile a binary from source
Step 5: Install the compiled binary program
To install the program, you should have administrative privileges.
In Fedora Linux, you use the following command :
$ su -c 'make install'
In Debian / Ubuntu, you should use the following command :
$ sudo make install
SUCCESS! Now you have finished compiling from source and installing software in Linux.
Read further only if you have encountered an error while configuring.
Possible error you might encounter in Step 3
Package requirements not met
When I first ran the
./configure command in step 3, it exited with the following error.
... checking for GIMP... configure: error: Package requirements (gimp-2.0 >= 2.3.0 gimpui-2.0 >= 2.3.0) were not met: No package 'gimp-2.0' found No package 'gimpui-2.0' found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables GIMP_CFLAGS and GIMP_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
Root cause of error – The GIMP development libraries are missing in my system.
Solution – Install the
su -c 'yum install gimp-devel'
gimp-devel package is required because in my case, I wanted to compile a plugin related to GIMP.
Once I installed the
gimp-devel package, and re-ran the
./configure script in Step 3, everything went like clock work and the configure script exited without any errors.