Compiling from source is necessary when software isn't in your distro's repository, you need a newer version, or want custom features; 1. Install build tools like build-essential or base-devel and required libraries; 2. Get source code via git or tarball from project sites; 3. Run ./configure or cmake to set build options and check dependencies; 4. Compile with make -j$(nproc) for faster builds; 5. Install with sudo make install, but track manually or use checkinstall to create packages for easier removal, and always verify sources and document steps to ensure safety and maintainability.
Compiling software from source on Linux gives you control over features, optimizations, and access to the latest versions not yet available in your distribution’s repositories. While package managers like apt
, dnf
, or pacman
are convenient, building from source is essential when you need custom configurations or bleeding-edge updates. Here's a practical guide to help you do it safely and effectively.

Why Compile from Source?
You might need to compile software from source for several reasons:
- The software isn’t available in your distro’s package manager.
- You need a newer version than what’s provided.
- You want to enable or disable specific features (e.g., support for a codec or plugin).
- You're a developer testing changes or contributing to the project.
However, keep in mind: manually compiled software isn’t managed by your package manager, which can complicate updates and removals.

Step-by-Step: How to Compile from Source
1. Install Build Tools and Dependencies
Most Linux distributions don’t include compilation tools by default. You’ll need a compiler (like GCC), make
, and other utilities.
On Debian/Ubuntu:

sudo apt update sudo apt install build-essential autoconf automake libtool
On Fedora/RHEL:
sudo dnf groupinstall "Development Tools" sudo dnf install autoconf automake libtool
On Arch Linux:
sudo pacman -S base-devel
You’ll also need any library dependencies required by the software (e.g., libssl-dev
, zlib1g-dev
). These are often listed in README
or INSTALL
files.
? Pro tip: Look for a
requirements.txt
,INSTALL.md
, orBUILDING.md
in the source directory. Many projects now include detailed build instructions.
2. Get the Source Code
You can usually download source code from:
- Project websites (e.g., http://ipnx.cn/link/13c0a0edfa0a93c79ff4c6b17dd8d9fb)
- GitHub, GitLab, or other code hosting platforms
Using git
(recommended for active projects):
git clone https://github.com/user/project-name.git cd project-name
Or download a release tarball:
wget https://example.com/project-1.0.tar.gz tar -xzf project-1.0.tar.gz cd project-1.0
3. Configure the Build
Most open-source projects use the GNU Autotools (configure
script). Run:
./configure
This checks your system for dependencies, sets up build options, and generates Makefiles.
Common configure
options:
--prefix=/usr/local
– Install to/usr/local
(default)--enable-feature
– Turn on optional features--disable-feature
– Turn off features you don’t need--with-library
– Specify external library paths
Example:
./configure --prefix=/usr/local --enable-ssl --disable-debug
?? If
configure
fails, it will tell you which dependencies are missing. Install them and try again.
For CMake-based projects:
mkdir build && cd build cmake ..
CMake uses cmake
instead of configure
, and options are passed with -D
.
4. Compile the Software
Once configured, compile with:
make
This reads the Makefile and compiles the source code. Depending on the software, this can take seconds or hours.
To speed things up, use multiple CPU cores:
make -j$(nproc)
5. Install the Software
After successful compilation:
sudo make install
This copies binaries, libraries, and configuration files to their final locations (e.g., /usr/local/bin
).
? Warning: Installing with
sudo make install
bypasses the package manager. You won’t be able to easily uninstall or track what was installed.
Alternative: Use make install DESTDIR=/path/to/staging
to create a package or test installation.
Managing Manually Installed Software
Since the package manager doesn’t track your builds, consider:
Keeping a log of what you compiled and which options you used.
Using tools like
checkinstall
(on Debian/Ubuntu) to generate a.deb
or.rpm
package:sudo checkinstall
This lets you uninstall via
dpkg
orrpm
later.Or use containers or local prefixes (e.g.,
--prefix=$HOME/.local
) to avoid system-wide changes.“Command not found” after install?
Make sure yourPATH
includes the install prefix (e.g.,/usr/local/bin
).Missing header files or libraries?
Install the corresponding-dev
or-devel
package (e.g.,libcurl4-openssl-dev
).Permission denied when running
make install
?
Usesudo
, but be cautious—double-check the install prefix.Out of disk space during build?
Compilation can require a lot of temporary space. Clean up withmake clean
when done.
Troubleshooting Common Issues
Final Notes
Compiling from source isn’t always necessary, but it’s a valuable skill. It gives you flexibility and deeper understanding of how software works on Linux.
Stick to trusted sources, verify checksums or GPG signatures when possible, and document your steps.
Basically, if you can read the README
, install dependencies, and run configure
, make
, and make install
, you’re good to go. It’s not magic—just code being built where you control the knobs.
The above is the detailed content of A Guide to Compiling Software from Source on Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

The key steps for creating a self-signed SSL certificate are as follows: 1. Generate the private key, use the command opensslgenrsa-outselfsigned.key2048 to generate a 2048-bit RSA private key file, optional parameter -aes256 to achieve password protection; 2. Create a certificate request (CSR), run opensslreq-new-keyselfsigned.key-outselfsigned.csr and fill in the relevant information, especially the "CommonName" field; 3. Generate the certificate by self-signed, and use opensslx509-req-days365-inselfsigned.csr-signk

Firefox browser is the default browser for most modern Linux distributions such as Ubuntu, Mint, and Fedora. Initially, its performance might be impressive, however, with the passage of time, you might notice that your browser is not as fast and resp

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

If you find that the server is running slowly or the memory usage is too high, you should check the cause before operating. First, you need to check the system resource usage, use top, htop, free-h, iostat, ss-antp and other commands to check CPU, memory, disk I/O and network connections; secondly, analyze specific process problems, and track the behavior of high-occupancy processes through tools such as ps, jstack, strace; then check logs and monitoring data, view OOM records, exception requests, slow queries and other clues; finally, targeted processing is carried out based on common reasons such as memory leaks, connection pool exhaustion, cache failure storms, and timing task conflicts, optimize code logic, set up a timeout retry mechanism, add current limit fuses, and regularly pressure measurement and evaluation resources.

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

Frankly speaking, I cannot recall the last time I used a PC with a CD/DVD drive. This is thanks to the ever-evolving tech industry which has seen optical disks replaced by USB drives and other smaller and compact storage media that offer more storage
![Installation and Review of Q4OS Linux [Lightweight Distro]](https://img.php.cn/upload/article/001/242/473/175150507396452.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
Q4OS is a new Linux distribution that’s based on Debian; a common base that’s shared with other distributions like Ubuntu and Linux Mint. It’s aimed at users who just want a simple, stable, easy to use Linux operating system that they can convenientl
