Open-Source Internship opportunity by OpenGenus for programmers. Apply now.
In this article, we have explored how to build and install GDB from source code and release package. The source code comes along with binutils while the release package has only GDB.
There are two approaches to build and install GDB from source:
- Use GDB release package
- Use Binutils-GDB source code
The simple way to install GDB is:
sudo apt-get update
sudo apt-get install gdb
If it does not work or you need a specific version, then following steps further in this article to build and install GDB from source code.
Use Binutils-GDB source code
Binutils and GDB were two distinct projects but in 2015, both have been merged into a single project named Binutils-GDB. So, if you get the source code from master branch, we need to build both Binutils and GDB.
If you want to build GDB only, then follow the steps in the next section "Use GDB release package".
To build GDB using Binutils-GDB source code, follow the steps in this guide.
Use GDB release package
In this, we download the release package of GDB which has the source code for GDB only. We can build and install this.
- Find the release package you want to download from the following link:
https://ftp.gnu.org/gnu/gdb/
We will take the latest version v12.1. Download it using the following command:
wget https://ftp.gnu.org/gnu/gdb/gdb-12.1.tar.gz
Extract the source code using the following command:
tar -xvzf gdb-12.1.tar.gz
Following the following commands to build GDB:
cd gdb-12.1
./configure
make
Install GDB:
make install
This will install it in /usr/local/lib.
Once installed, make sure that GDB is available in the system using the following command:
gdb --version
With this article at OpenGenus, you must have the complete idea of how to install GDB from source.