Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

It was wondering: when installing something, there's an easy way of double clicking an install executable file, and on the other hand, there is a way of building it from source.

The latter one, downloading a source bundle, is really cumbersome.

But what is the fundamental difference between these two methods?

share|improve this question

4 Answers 4

up vote 25 down vote accepted

All software are programs, which are also called source packages. So all source packages need to be built first, to run on your system.

The binary packages are one that are already build from source by someone with general features and parameters provided in the software so that a large number of users can install and use it.

Binary packages are easy to install.
But may not have all options from the upstream package.

So for installing from source, you need to build the source code yourself. That means you need to take care of the dependencies yourself. Also you need to be aware of all the features of the package so that you can build it accordingly.

Advantages of installing from source:

  • You can install the latest version and can always stay updated, whether it be a security patch or a new feature.
  • Allows you to trim down the features while installing so as to suit your needs.
  • Similarly you can add some features which may not be provided in the binary.
  • Install it in a location you wish.
  • In case of some software you may provide your hardware specific info for a suitable installation.

In short installing from source gives you heavy customization option at the same time it takes a lot of effort, while installation from binary is easier but you may not be able to customize as you wish.

Update: Adding the argument related to security in the comments below. Yes it is true that while installing from binary you don't have the integrity of the source code. But then it depends as to where you have got the binary from. There are lots of trusted sources from where you can get the binary of any new project, the only negative is the time. It may take some time for the binary of the updates or even a new project to appear in our trusted repositories.

And above all things, about software security, I'd like to highlight this hilarious page at bell-labs provided by Joe in the below comments.

share|improve this answer
3  
source also can be compiled in an optimised way for your system (which.. may not be a good idea, as then the compiled stuff is "specific" to the system and may not work on a backup one... but you have the source, you can recompile (if you have time for that)) –  Olivier Dulac Aug 27 at 9:44
    
This depends on if you have that "backup system" at all. If you are just doing some research, you typically do not. –  Audrius Meškauskas Aug 27 at 13:02
1  
For the hyperparanoid, one advantage of installing from source is security and the ability to review the code if you are able to and or want to: when you install from source, you know for a fact you have a binary from that source code and not a binary with unknown modifications (assuming you trust the source in the first place). –  ultrasawblade Aug 28 at 12:31
4  
@ultrasawblade - You're obviously not paranoid enough! <G> - see cm.bell-labs.com/who/ken/trust.html for the full monty. –  Joe Aug 30 at 5:15

A source file contains the original code as written by the developer in whatever language he/she chooses (C, C++, Python etc),and is generic. It isn't specific to any distro and in many cases to any operating system.

A package (RPM or DEB for example) is the binary executable (or interpreted script etc) pre-prepared for your particular distro. The task of preparing the source for compiling (adding any necessary patches etc), the actual compile, creating distro specific config files, creating pre and post install scripts etc are all done for you by the package maintainer.

In other words, all the donkey work has been done for you in a package, whereas you'll need to do it yourself if you choose to install from source.

It is much easier to use a package in nearly all cases as:

  • They are much easier to install
  • They are specifically designed to work with your distro
  • They are sometimes patched by the package maintainer to fix distro specific bugs
  • The package manager will uninstall them
  • The package manager will manage all dependencies for you
  • The package manager will take care of updates
  • You don't need to install developer tools on your system (compilers, make etc)

However, sometimes the packaged version is an old version or even worse, there is no packaged version; in which case your only option is to compile yourself. If you do, you need to consider the following:

  • You'll need to install all the developer tools on your system
  • You will be responsible for checking for an update and recompiling
  • You will need to make sure all the dependencies are installed, including dev packages - there could be many of them.
  • You may need to debug problems if it doesn't work as expected on your distro

If you are willing to put in the extra effort, then compiling from source may give you the benefits of:

  • Access to the latest available version
  • The option of optimizing the compiling process for performance/stability
  • Enjoyment!

Note that while some distros' pre-built packages provide binary executables which are ready to install and run (RPM and DEB are examples), other distros provide packages that simply automate the process of compiling.

Gentoo's ebuilds is an example of this - the package is basically instructions to the package manager describing how to compile and install the executable. This has many of the advantage of traditional package managers (automatic updates, uninstalling etc) while still allowing the user to optimize the compiling process to his/her taste.

Arch Linux has a packaging system where the mainstream packages are binary while many extra packages are compiled on the system using PKGBUILD files.

share|improve this answer
    
+1 for mention of Gentoo/portage –  Vality Aug 28 at 1:15

Apart from the other answers, I would like to add something:

If you decide to compile a program by yourself, you need to think that compiling is not something you do only once. You will probably need to subscribe to the development mailing list of the applications you decided to compile and stay up to date with the new versions and, especially, the security updates.

Every time the application is updated you will have to recompile the new version so, just keep in mind that you will have to spare some of your time every week.

If you cannot afford that, it is better to let the package maintainer do that job for you.

share|improve this answer

Building from the source allows to specify architecture of exactly your machine. New CPUs have additional instructions that compilers do understand, squeezing out a little bit of performance. Pre-build packages usually count on the most archaic CPU still in common use.

This is mostly important for project-critical applications that use CPU very heavily, such as tools of bioinformatical pipeline, for instance, or geophysical modelling tools. Such software runs in a very controlled environment, does not feature access control on its own, so seldom has security bugs so urgent that they must be patched in days or hours. Almost never it needs to run on a different machine with initially unknown architecture.

Yes, I known, computers are very very very fast now and any efforts or actions you take are very very very expensive, but on the third day of sitting and waiting your program to complete (this is the situation I am talking about) such truths start looking questionable.

Differently, applications like browsers and the like should be better used from the maintainer repository (and not from some downloaded pre-built packages), as it is very important to keep them up to date.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.