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:
We will take the latest version v12.1. Download it using the following command:
Extract the source code using the following command:
tar -xvzf gdb-12.1.tar.gz
Following the following commands to build GDB:
This will install it in /usr/local/lib.
Once installed, make sure that GDB is available in the system using the following command:
With this article at OpenGenus, you must have the complete idea of how to install GDB from source.