How to Compile from Source Code in Linux

The standard process for compiling and installing an application from source usually follows these steps:

Download and Extract: Download the source code, which is usually a compressed archive (.tar.gz, .tar.bz2, etc.).

Configure: Run the ./configure …


This content originally appeared on DEV Community and was authored by Harry Tanama

The standard process for compiling and installing an application from source usually follows these steps:

Download and Extract: Download the source code, which is usually a compressed archive (.tar.gz, .tar.bz2, etc.).

Configure: Run the ./configure script (if it exists) to check for dependencies and prepare the Makefile.

./configure

Compile: Run the make command to compile the code.

make

Install: Run sudo make install to install the final binary and its associated files to the system.

sudo make install

Important Note: Always check the README or INSTALL files that come with the source code, as the build process can vary significantly between projects.

For local installation

./configure --prefix=$HOME/.local

make

make install

Cmake

Build software application using CMake:

mkdir build
cd build

Configure with a CMAKE_INSTALL_PREFIX: You specify the installation directory when running cmake.

cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local

The .. tells cmake to look for the CMakeLists.txt file in the parent directory.

Compile and Install:

make

make install

Making the Binaries Accessible

After a local installation, the executable files are in a directory like ~/.local/bin, but your shell might not know where to find them. To fix this, you need to add this directory to your PATH environment variable.

You can do this by adding the following line to your shell's configuration file (e.g., ~/.bashrc or ~/.zshrc):

export PATH=$HOME/.local/bin:$PATH


This content originally appeared on DEV Community and was authored by Harry Tanama


Print Share Comment Cite Upload Translate Updates
APA

Harry Tanama | Sciencx (2025-08-03T04:15:01+00:00) How to Compile from Source Code in Linux. Retrieved from https://www.scien.cx/2025/08/03/how-to-compile-from-source-code-in-linux/

MLA
" » How to Compile from Source Code in Linux." Harry Tanama | Sciencx - Sunday August 3, 2025, https://www.scien.cx/2025/08/03/how-to-compile-from-source-code-in-linux/
HARVARD
Harry Tanama | Sciencx Sunday August 3, 2025 » How to Compile from Source Code in Linux., viewed ,<https://www.scien.cx/2025/08/03/how-to-compile-from-source-code-in-linux/>
VANCOUVER
Harry Tanama | Sciencx - » How to Compile from Source Code in Linux. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/03/how-to-compile-from-source-code-in-linux/
CHICAGO
" » How to Compile from Source Code in Linux." Harry Tanama | Sciencx - Accessed . https://www.scien.cx/2025/08/03/how-to-compile-from-source-code-in-linux/
IEEE
" » How to Compile from Source Code in Linux." Harry Tanama | Sciencx [Online]. Available: https://www.scien.cx/2025/08/03/how-to-compile-from-source-code-in-linux/. [Accessed: ]
rf:citation
» How to Compile from Source Code in Linux | Harry Tanama | Sciencx | https://www.scien.cx/2025/08/03/how-to-compile-from-source-code-in-linux/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.