[How To] Compile and Install a Program From Sources
->
In this day modern day, most software installations can be done using repositories and package managers. However, you might face a situation of having only the source files availalble with you – you probably would want to try out bleeding edge software, which hasn’t been packaged yet, or isn’t available in the repos yet.
So if you really want to try it out, then the only way would be to download the source files and compile them.
Contrary to what most people think – Compiling from sources isn’t that complicated – the entire process takes 3 commands.
- ./configure
- make
- make install
Let’s have a look at each of these steps now.
Prerequisites
Before you start compiling, you need to extact the source files, as most of them come as either tar(.tar), gzipped tar(.tar.gz , .tgz) or as bzipped tar file(.tar.bz2). Any decent archiver should extract it. You can do it via the command line by typing
tar xvfz package-name.tar.gz (for gzipped files) or
tar xvfj package-name.tar.bz2 (for bzipped files)
You should also have the required header files(kernel header files, tools such as gcc, make, bison etc). Don’t worry, if you’re missing any one file the configure step will tell you something is missing.
Compiling
Let’s now get to the compiling stage.First cd to the directory where you extracted the files by typing
cd /path/to/directory/of/source
Then type
./configure
Yes, the “.” is there. This step just checks your system and assigns values for system-dependent variables. These values are used for generating a Makefile. The Makefile in turn is used for generating the actual binary.
For example, here’s a snippet of the messages that might be flowing
checking dynamic linker characteristics… GNU/Linux ld.so
checking whether to build static libraries… no
configure: creating libtool
checking for ppoll… yes
checking for pkg-config… /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0… yes
checking for BLUEZ… yes
checking for GLIB… yes
checking for GMODULE… yes
checking for dlopen in -ldl… yes
If some file or library is missing, you’ll get a message like
checking for DBUS… no
configure: error: D-Bus library is required
If all is fine,the configure program will exit gracefully, like this
config.status: creating test/Makefile
config.status: creating scripts/Makefile
config.status: creating config.h
config.status: executing depfiles commands
sathya@sathya:~/bluez-utils-3.36>
Next, we issue the make command,
sathya@sathya:~/bluez-utils-3.36> make
This will do the actual build and compile of the sources. Again you’ll see a bunch of weird messages flowing by the screen(geek porn!
) and once done, you’ll fall back to the prompt. Again if some error has occurred you will be notified
Installation
The final step, is to install the binaries and the libraries that were built in the above step. This requires root privileges. So for that su to root and and issue the make install command
sathya@sathya:~/bluez-utils-3.36>su root
root@sathya:~/bluez-utils-3.36>make install
That’s it! You’ve successfully compiled the program from its source and installed it. Easy isn’t it?
Some notes:
- The package will contain a README or an INSTALL file. It’s recommended that you read it before you start compiling, so that you might be spared of some nasty surprises
- Uninstalling programs installed by the above step is tricky, you can’t use package managers to remove them. For that you’ll have to cd to directory where you installed it from and issue make uninstall. For this reason I recommend, that you keep a separate directory for storing all these “compile-from-source” type of files
Popularity: 3% [?]
If you enjoyed this post, make sure you subscribe to my RSS feed!
Possibly Related posts:If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.
Comments
Errr just because its a .tar.gz doesn’t mean it contains sources all the time
What you’re assuming is equivalent of saying a Zip file must always contain source files ![]()
![]()
Anyways.how I can make the icons for programs that I extract to appear in the “applications” tab?
Is there a folder for it like Windows has for Start Menu and Quick launch?
Want to know their exact addresses.
@Reeteshinator
Firefox tar file usually contains the binaries. Just extract and copy it to somewhere are execute the firefox file using ./firefox command.





Finally the site loads!
Oh and I got thunderbird from mozilla website as a tar.gz file, I tried to install it just like this, but the thing is that it doesn’t have a “./configure” thing.
I realised that it has all the executables and everything in it itself.. so does that mean I should just place it somewhere and create a shortcut on my own and use it?
i.e many people just compress things in tar.gz and distribute even though its not a source?
Hmm. I think I answered my own question..but yeah. its like that also, right?