Why is it better to compile than to install from the repositories

In this little guide I am going to explain (and teach you) why it is better that you compile a program (say Firefox, Vlc, etc) from its source code, than download it (from The Software Center, Yumex, Pacman, etc) and install.

First we go with the theory:

What is "compile"?

Compiling is transforming the source code (code written in a certain programming language, say C, C ++, etc.) into an executable program for its operation by using the processor to convert the language used to generate the code to binary and assembler . It is also often called packaging.

Why is it better to "compile"?

First you have to know the following to understand why. Put in a "crude" way (simple, not very professional, etc), each race (Pentium, Core, Atom, etc) and its species (Intel, AMD, ARM, etc.) of processor have instructions (software written in assembler that processes the code) of their model (Core i7, Core i5, Atom x2, Phantom x8, Arm, etc.) and also have general instructions that all of their kind have.

When you download a program from the repositories via the Software Center (e.g., apt-get/Yumex/Yum/Pacman/etc), it's automatically installed and said to be precompiled to run on all possible processors (Intel and AMD). Because it's a precompiled program, it loses the instructions specific to that particular processor model (imagine if a program like Firefox or Chrome, which have over 7 or 8 million lines of code, had to include all the specific instructions for every processor on the market; the amount of code would be so large that the program would no longer be efficient), retaining only the general instructions of its creator (Intel, AMD, ARM).

When you download, decompress, and compile the source code of a program yourself, it is compiled with the specific instructions of YOUR processor ( which doesn't mean it won't work on a machine with a different processor, only that it will be optimized specifically and purely for your processor) , thus unleashing and freeing all the power that your processor is capable of giving thanks to its specific instructions.

In more technical details, these specific instructions are closely linked to what is known as the chipset of your motherboard, which is the great headache for those of us who have Intel when we want to upgrade the processor and the motherboard.

You'd be surprised by the power your old PC's AMD Atom x2 or Intel Core i3 , Core 2 Duo , or other processor can deliver . Now you understand why compiling the famous kernel (the heart of every operating system) is so much talk in the Linux world? Imagine if you could compile an entire system specifically for your PC (graphical environment (GNOME, KDE, etc.), kernel, commonly used programs (Firefox, VLC, Chrome, Wine, etc.))—the level of speed and optimization you'd get.

This compilation principle to obtain a code optimized especially for your machine is the one used by distros such as Gentoo and derivatives (which I am not going to talk about now, I use Fedora minimal with compilation of Gnome 3, the kernel and other programs) where the system , your updates and your programs are always compiled.

Cons of compilation:

I already explained all the advantages, but like everything in the universe it has one against.

In the compilation case they are;

  • Time needed for this (Firefox with an i7 4790K (without overclock since I'm very bad with voltages) takes 3 minutes, Gnome Shell (the bar nothing else) with Gnome-Control-Center took me about 2 minutes, both being compiled at the same time in Fedora. But on a machine with a less powerful processor this time can be disproportionately long).
  • The processor uses 100% of its power with all its cores at maximum, so consumption and heat skyrocket (take this into account if you have overclocking or if it is especially a notebook), so it is convenient that you prepare a mate or a coffee for the occasion.
  • Perhaps you are missing a library (tool) that uses a program so that it does not error in the compilation. In general, all distros have packages or sets of them to avoid this (they are packed with various libraries and other things that allow the kernel to communicate as it should with the processor during the process).

How can I compile?

For Debian (Ubuntu, Mint, Elementary, etc they are all derivatives of this so follow this

Here I am talking about compiling a program for normal use, not a kernel.

aptitude install build-essential dh-make devscripts fakeroot debhelper debian-policy ccache dh-autoreconf autotools-dev build-dep ardor

I put debian-policy, but if your distro is not Debian and it gives you an error that no such package exists, just ignore it. I have to clarify that I have not used these systems for a long time, so if a package is no longer in the repositories, do not worry.

For Fedora:

sudo yum -y install kernel-headers
kernel-devel
sudo yum groupinstall "Development Tools"
sudo yum groupinstall "Development Libraries"

Here I have to apologize for those who use Arch (I do not know the distro well) and OpenSuse, since I do not know these distros or the respective packages to perform a correct compilation (and I have not corroborated what is on the network, so that for those two I don't know if they work).

Now that you have all the necessary requirements, you only need to download the source code of the program you want to compile, depending on the extension you unzip it using the terminal (don't worry, I'll leave you the commands) and when you go to the folder (always with the terminal) you do the same next:

If you have the possibility to configure yourself to choose the components and others:

./configure

Then you type:

make

And finally to install the program on your linux:

make install

All this always with root (su in Fedora, sudo su in Ubuntu and its derivatives (Mint, Elementary Os, etc)

Commands to unzip using the terminal (the file is unzipped in a folder where the file is located):

.Tar files (tar) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Pack | tar cvf file.tar / file / * Unpack | tar xvf file.tar View content | tar tvf file.tar
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .tar.gz - .tar.z - .tgz (tar with gzip) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Pack and zip | tar czvf file.tar.gz / file / Unpack and unzip | tar xzvf file.tar.gz View content (not extracted) | tar tzvf file.tar.gz
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .gz (gzip) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compress | gzip -q file (The file compresses and renames it "file.gz") Unzip | gzip -d file.gz (The file unzips it and leaves it as "file" Note: gzip only compresses files, not directories
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .bz2 (bzip2) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compress | bzip2 file | bunzip2 file (The file compresses and renames it "file.bz2") Unzip | bzip2 -d file.bz2 | bunzip2 file.bz2 (The file unzips it and leaves it as "file") Note: bzip2 only compresses files, not directories
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .tar.bz2 (tar with bzip2) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compress | tar -c files | bzip2> file.tar.bz2 Unzip | bzip2 -dc file.tar.bz2 | tar -xv | tar jvxf file.tar.bz2 (recent versions of tar) View content | bzip2 -dc file.tar.bz2 | tar -tv
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .zip (zip) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compress | zip file.zip / mayo / archives Unzip | unzip file.zip View content | unzip -v file.zip
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .rar (rar) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compress | rar -a file.rar / may / archives Unzip | rar -x file.rar View content | rar -v file.rar | rar -l file.rar

And that's all. Greetings from Buenos Aires, Argentina. Happy Holidays and New Years! :).


Add as preferred source in Google