What is the difference between building from source and using an install package?
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.
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.
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.