Installing programs from source code ………….. have you done it before? (tutorial)

February 21, 2009 at 9:11 pm (Linux installation) (, , , , , , )

This article is intended for intermediate users on how to compile from the source code.

As I mentioned before, it’s a free and open source world that we are living. So people who want to help others not only just give away the programs, but they give out the source code (the program codes used to build the program) in order to modify, learn the codings ,algorithms used, so that other people can use that code to build something much more better ! That’s how FOSS came this far down the lane, and it seems to get more and more enthusiastic !

As you know, source code as well as the pre-compiled binaries (ex: rpm, deb, bin) are available to download in the FOSS cloud. See far down this article to see when you do need to go for the source.

Short eats for beginners

basic steps to install

open commandline, CD in to the folder where you have the tarball (.tar.gz,.tar.bz2)

untar the source file using tar -xvf <filename>

CD in to source folder

then type

sudo ./configure && make && make install

or type su – , enter the root password and type

./configure && make && make install

If you have luck you’ll succeed. Read down for more deatiled description.

How to get source codes of programs?

There are several sites hosting FOSS programs, but I would suggest you go and check out, freshmeat and softpedia linux page. When you come to the download page you will find a list of files to download. Don’t download unstable editions. Source file is something usually in .tar.gz or .tar.bz2 format saying “any platform” , sometimes may be categorized under “other OS”.

The source folder

(from here you should use console/terminal)

A typical view of the source folder

A typical view of the source folder

Change directory using CD command to the path you saved your file

Untar the downloaded file either using tar -xvf <filename> (ex: tar -xvf mplayer-1.02RC3.tar.gz) or your OS’s GUI extractor (ex: fileroller) to a folder newly created by mkdir <newdirectoryname> command. (I guess you know these)

now CD in to the folders till you find some lot of files (see below – use command ls for list the files in each directory) which is called the source folder. It usually includes a README, INSTALL, COPYING, configure and Makefile. (Doesn’t need to have all of these)

Task of these files: (can be omitted in a short course)

configure – Sources are designed to install with any system, but how it should install in a given system is heavily different. It depends on your hardware, software and “your choice”. When run, this will make a config.h, config.status and various config files and a unique Makefile

Makefile – Make file includes the code to compile the program calling files from source folder. – capable of generating a configure file

README – YOU MUST READ THIS FILE ! It includes information about the program, and dependencies etc. use command


INSTALL – YOU SHOULD READ THIS TOO ! This gives specific information on how to install program.

Start compiling

Start with ./configure –help

this gives out some flags like below ones: (features of install)

flags you need to note:

–prefix=<path where you want to install files> , by default this will be /usr/local/bin etc…

–with-<packagename> ,will use the given package (as in the list)

–without-<packagename> , will not use

–enable-<feature>, enable a feature in the program

–<packagename>-includedir or -includes , manually override the search path for dependencies

now start configuring by

./configure flag1 flag2 flag3 etc….

ex: ./configure –prefix=/mnt/storage/mplayer –enable-gui –without-libmad

or just type ./configure only, this will work for most programs and easy for beginners

A typical text output when configure is run

A typical text output when configure is run

the program will display text as it is checking for dependencies, it will stop if it found out that a critical component is missing (or can’t find) and will display error and the package failed in someway. (see debugging below) if you’re lucky the text will show up to the point it’s writing config files ! Some advanced programs will show a list of things it’s planning to install, according to your dependencies.

Now type


This is gonna take some long time —— and this is where you need the luck most as many programs fail here ! (Now you say that) when done, type (see below the picture)

The make has failed - you should need to re configure

The make has failed - you should need to re configure

sudo make install

or log in to root typing su – then type make install

this will install the program. If you didn’t use “–prefix=” above, you”ll have binaries in your PATH so type

ls *<name of program you installed>*

ex: ls *mplayer* , this will give you a list of possible commands to run the program. Type them and see the correct one. (there’s a possiblity you may have a link in desktop) if you installed somewhere else go inside that folder. You may find the script usually in bin folder. Type


to run program.


1. There’s a possibility that you don’t have a configure file. Anyway,
still you have – What you downloaded is a snapshot. Type ./ to generate configure file.
You have Makefile – no need to do “./configure” only do make and make install steps.
You have some files named cmake – your program does not install from ordinary automake. It’s using a program called cmake. Make a folder named “build” in your source folder and type

cmake ../ -DCMAKE_INSTALL_PREFIX=<path of your source folder>/build
and continue with make and make install
You have some .jar files – Source code is java. (Sorry i’m NIL at java, anyway try java -jar filename.jar)

2. If Config says you don’t have a package installed or something like that it could be due to

*You actually don’t have program installed. Copy the name in to google search and try to find it’s homepage to download. If you are installing binaries (ex: rpm) make sure you have both the “package” (has the program) and “package-devel” (has header files .h to develop the program)

ex: if it says “WxWidgets not found” install both “WxWidgets” and “WxWidgets-devel”

(there may be an article on my blog about manual rpm installation). If you only have the “package” configure will still say that you don’t have the package.

*You have the program and devel installed, but configure is searching some where else. Type

locate <packagename> | less

to list the files, the folder path having most “.h” files with “include” in path name may be where your header files are. Copy that path and do configure again using –<packagename>-includedir flag.

Ex: ./configure –Qt4-includedir=/usr/include/Qt4

3. If you still can’t debug it you may need to edit the configure file (not recommended), copy the error message and type

gedit configure

or if you have kwrite, nano other editor, use that command. Use find option pasting the error message. If you have some programming knowledge you should be able to identify the default paths assigned for searching for the package. Correct them to your actual path.

(For example, package WxGTK is installed as compat-WxGTK in fedora, so I had to tell the program that compat-WxGTK is the correct one while installing audicity ).

Man, this is getting longer and longer so i’ll stop here. You can always google search for the error message, where people may have solved it before have put how they did it. (Of course you can ask me)

It’s a good practice to type

make clean

to remove the make files after installation or failed make attempt.

You can type this to uninstall, if you’re at the source folder.

make uninstall

so I suggest you shouldn’t delete the source folder just after successful installation !

Some configure scripts will need

make depend

make check

commands between the make and make install. These will be mentioned in INSTALL file.

When should you go for source?

  • If you are a developer, who either using the code for modifications or a someone who’s building binary repositories for various Linux distributions by cross-compiling
  • You don’t have a package managing system (ex: rpm,deb) or only the source code is available so you don’t have a choice
  • The program is large or it has many unwanted features which is again large and asking for a list of dependencies to run when you try to install the .rpm or .deb (you can select features to install by source code – saves a lot of space)
  • Person who want to grab the newest edition
  • Some programs have tweaks (optimizations) chosen when compiling depending on your system. This enhances performance of program (ex: wine, mplayer, swiftfox)

Important: Anyway, use the source mainly for programs up in the dependency tree (programs which heavily depend on other programs but which is not a dependency of any program) if you have a package manager (as it may not identify the installed program).

I’ll stop here for now. This blog page will be updated as necessary in the future.



  1. කෙහෙළිය බණ්ඩාර ගල්ලබ said,

    so simple .. & .. so informative .. thnx machan

  2. Hydrogen - The GNU Drum Machine « Malshan’s Linux Blog said,

    […] install the program, you can always see my article on “compiling from source” if […]

  3. LMMS (Linux Multimedia Studio) - a FL Studio like FOSS program « Malshan’s Linux Blog said,

    […] source for the LMMS is to be compiled from Cmake. You can download it from this link. You can see my tutorial on compiling from source, or see the INSTALL file on the source folder. It reads: go to the source folder in the command […]

  4. Gnash – The FOSS Shockwave flash player « Malshan’s Linux Blog said,

    […] make install will do the job, for more information on how to compile from source click here. […]

  5. Adding A/V support for linux: Install Mplayer « Malshan’s Linux Blog said,

    […] for my “Compiling Linux apps from source” page for more help.  LikeBe the first to like this […]

  6. Play music on command line « Malshan’s Linux Blog said,

    […] && make && install as root to compile and install. See my article on compiling from source for more […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: