search
HomeSystem TutorialLINUXBinary packages vs source code packages under Linux: Which should you choose?
Binary packages vs source code packages under Linux: Which should you choose?Feb 14, 2024 pm 07:06 PM
linuxlinux tutoriallinux systemLinux operating systemlinux commandshell scriptembeddedlinuxGetting started with linuxlinux learning

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?

Linux 下二进制包 vs 源代码包:你应该选择哪个?

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"?

Linux 下二进制包 vs 源代码包:你应该选择哪个?

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
Linux 下二进制包 vs 源代码包:你应该选择哪个?

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

Linux 下二进制包 vs 源代码包:你应该选择哪个?

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

Linux 下二进制包 vs 源代码包:你应该选择哪个?

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!

Statement
This article is reproduced at:良许Linux教程网. If there is any infringement, please contact admin@php.cn delete
什么是linux设备节点什么是linux设备节点Apr 18, 2022 pm 08:10 PM

linux设备节点是应用程序和设备驱动程序沟通的一个桥梁;设备节点被创建在“/dev”,是连接内核与用户层的枢纽,相当于硬盘的inode一样的东西,记录了硬件设备的位置和信息。设备节点使用户可以与内核进行硬件的沟通,读写设备以及其他的操作。

Linux中open和fopen的区别有哪些Linux中open和fopen的区别有哪些Apr 29, 2022 pm 06:57 PM

区别:1、open是UNIX系统调用函数,而fopen是ANSIC标准中的C语言库函数;2、open的移植性没fopen好;3、fopen只能操纵普通正规文件,而open可以操作普通文件、网络套接字等;4、open无缓冲,fopen有缓冲。

linux中什么叫端口映射linux中什么叫端口映射May 09, 2022 pm 01:49 PM

端口映射又称端口转发,是指将外部主机的IP地址的端口映射到Intranet中的一台计算机,当用户访问外网IP的这个端口时,服务器自动将请求映射到对应局域网内部的机器上;可以通过使用动态或固定的公共网络IP路由ADSL宽带路由器来实现。

linux中eof是什么linux中eof是什么May 07, 2022 pm 04:26 PM

在linux中,eof是自定义终止符,是“END Of File”的缩写;因为是自定义的终止符,所以eof就不是固定的,可以随意的设置别名,linux中按“ctrl+d”就代表eof,eof一般会配合cat命令用于多行文本输出,指文件末尾。

linux怎么判断pcre是否安装linux怎么判断pcre是否安装May 09, 2022 pm 04:14 PM

在linux中,可以利用“rpm -qa pcre”命令判断pcre是否安装;rpm命令专门用于管理各项套件,使用该命令后,若结果中出现pcre的版本信息,则表示pcre已经安装,若没有出现版本信息,则表示没有安装pcre。

linux怎么查询mac地址linux怎么查询mac地址Apr 24, 2022 pm 08:01 PM

linux查询mac地址的方法:1、打开系统,在桌面中点击鼠标右键,选择“打开终端”;2、在终端中,执行“ifconfig”命令,查看输出结果,在输出信息第四行中紧跟“ether”单词后的字符串就是mac地址。

手机远程linux工具有哪些手机远程linux工具有哪些Apr 29, 2022 pm 05:30 PM

手机远程linux工具有:1、JuiceSSH,是一款功能强大的安卓SSH客户端应用,可直接对linux服务进行管理;2、Termius,可以利用手机来连接Linux服务器;3、Termux,一个强大的远程终端工具;4、向日葵远程控制等等。

linux中rpc是什么意思linux中rpc是什么意思May 07, 2022 pm 04:48 PM

在linux中,rpc是远程过程调用的意思,是Reomote Procedure Call的缩写,特指一种隐藏了过程调用时实际通信细节的IPC方法;linux中通过RPC可以充分利用非共享内存的多处理器环境,提高系统资源的利用率。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools