


Binary packages vs source code packages under Linux: Which should you choose?
In Linux systems, the installation program is usually different from the traditional Windows installation software method. You can install it from a pre-built package or compile the program yourself. In those increasingly popular distributions, pre-built packages are often the primary solution. But sometimes, you may also need to compile from source code. This is also one of the characteristics of the Linux operating system. Compiling a program from source code ensures that the program will run properly on the system and allows for more flexibility and customization. No matter which method you choose, you need to choose the method that works best for you based on your needs.
What is a binary package?

Installing programs on Linux is usually different from the traditional way of installing software on Windows. Rather than downloading the installer from the vendor's website, the files come from a program repository, usually customized to your Linux distribution. You can access this repository using your Linux package manager or app store.
The programs in these repositories are composed of multiple files and packaged in an archive format for easy access and distribution. For example, Debian uses the DEB format to store and distribute programs. These packaged files are called binary packages.
How to read binary code
You need a special program to extract these files and install them on your computer, usually your package manager or app store. These tools also have other useful features, such as tracking installed files and managing software updates.
Newer package formats, such as Flatpak and Snap, work with different versions of Linux, but they still consist of precompiled binaries. Both require a graphical app store or a command line-based package manager for installation.
What is source code?
All software consists of lines of text called source code, written in a specific programming language, such as C or C++. Normally, you can't just package this source code into an archive file and call it a package. These lines need to be translated into a language that the computer can understand and execute.
This process is called compilation, and the end result is to create a binary file that the computer can run. The difference between a software package and software is that the binary files of software are stored in a package along with other files such as configuration files.
What is "install from source"?

Installing a program from source means installing without using a package manager. You need to compile the source code and copy the binaries to your computer.
In most cases, you can download the project's source code from a hosting service such as GitHub, GitLab, or Bitbucket. Larger programs may even host source code on a personal website. This code is usually compressed in an archive format (also called a source code package).
A special set of tools helps automate the build process. On the Linux desktop, it usually exists in the form of a command line program called make. Source code written in different languages requires specific compilers and commands to convert it into binaries. The make program automates this process.
To make this automation work, the program provides a file called Makefile that tells make what it should do and how to compile it. Nowadays, Makefiles are usually automatically generated by special software such as CMake. This is where you need to step in. From here, you can specify the specific functionality you want compiled into the software.
Example built from source
For example, the following command uses CMake to generate a configuration file for the Calligra office suite. The file created tells the make program to compile only Calligra's Writer component.
cmake -DPRODUCTSET=WORDS -DCMAKE_INSTALL_PREFIX=$HOME/kde/inst5 $HOME/kde/src/calligra
After completing this step, users can simply run the make tool to compile and copy the results to their computer. The steps are as follows:
make make install

Although this is the general mode for compiling a program, there are many other ways to install source code packages. For example, Gentoo Linux has a built-in way of handling source code packages, making the process faster and easier. But building a binary package requires more steps than the above command.
Benefits of using binary packages
If you use Linux, there is a good chance that someone has precompiled the software you have installed. This is more common than using source code packages. But why is this happening?
1. The binary version is easier to manage

Binary packages not only contain compiled installation files, but also store other information, making it easy for your package manager to keep track of all your programs. For example, DEB files (the package format for Debian and its derivatives) also contain important information such as other software required for the program to run and its current version.
This makes installing the package much simpler because you don't need to worry about what other files are needed to successfully run the program. Your package manager can read this information from the package itself and download all necessary dependencies automatically.
And when installing a program from source code, unless the code is compiled into a stand-alone binary package, you will be responsible for managing the software. You need to remember what other programs you need to make it work and install them yourself.
2. The binary version has better stability
People responsible for maintaining package manager repositories often test binaries and try to fix problems that arise. This may result in improved stability, as package maintainers may discover problems that may have been overlooked by those installing the source code.
Additionally, packages usually must adhere to a strict set of rules to ensure they will run on your system. For example, Debian and Ubuntu both have a policy manual, and many other Linux distributions have similar manuals.
Some programs also rely on different versions of the same software dependencies to run. The package repository will try its best to resolve these conflicts to avoid causing trouble for you.
Benefits of compiling source code packages
Installing a program from source is not something everyone needs to do, as it is usually easier to maintain your computer if you stick to binary packages. Still, there are some advantages to using this slightly more complicated way of installing a program.
1. Source code provides the latest software
One drawback to making a program more reliable is that it takes time to improve and fix. Sometimes there may be binaries available, but the source code will be provided later. For those who want to have the latest and greatest software, they may be willing to sacrifice a little stability while exchanging for newer software.
Although there are some Linux operating systems that can meet this need without compiling the program, they also have some disadvantages. For example, software that does not release fixed package versions frequently will have difficulty keeping up to date in the repository. In contrast, installing from source does not have these restrictions.
This is because binary packages are usually made based on officially released program versions. Therefore, changes between these versions are usually not taken into account. By compiling your own software from source code, you can benefit from these changes immediately.
It is also possible that your Linux operating system does not prepare the software you want for you in advance. In the past, this would have made installing from source the only option. Common package formats have changed this. Flatpak and Snap packages also generally receive updates faster than system repositories. But there are still times when compilation is the only way to get the software you want.
2. You can choose the function yourself

Function of FFmpeg Another benefit of using source code packages is that you have more control over the programs you install. When installing from a binary repository, you are limited in your ability to customize packages.
Take FFmpeg as an example, it is a command line-based audio and video conversion tool. By default, it comes with a ton of features, some of which you may never use. For example, FFmpeg supports JACK audio, although this software is typically only used in production environments.
By compiling FFmpeg, you can remove features you don't need and make it more lightweight and fit your needs. The same principle applies to other huge programs.
When resources are limited, removing functions can effectively reduce the load. It's no wonder that Gentoo Linux-based ChromeOS is used on many low-end computers. Gentoo is based on source code and compiles many software, potentially making these systems lighter to run.
Why not use both binary and source packages?
While you may not want to compile packages every day, this is a useful approach. Still, with the new universal package format available from sites like the Snap Store and Flathub, you're less likely to need to build from source to get the latest software.
The above is the detailed content of Binary packages vs source code packages under Linux: Which should you choose?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.
