How To Install cscope on Ubuntu 20.04

In this tutorial we learn how to install cscope on Ubuntu 20.04. cscope is interactively examine a C program source

Introduction

In this tutorial we learn how to install cscope on Ubuntu 20.04.

What is cscope

cscope is:

Cscope is an interactive text screen based source browsing tool. Although it is primarily designed to search C code (including lex and yacc files), it can also be used for C++ code.

Using cscope, you can easily search for where symbols are used and defined. Cscope is designed to answer questions like:

  • Where is this variable used?
  • What is the value of this preprocessor symbol?
  • Where is this function in the source files?
  • What functions call this function?
  • What functions are called by this function?
  • Where does the message “out of space” come from?
  • Where is this source file in the directory structure?
  • What files include this header file?

There are three methods to install cscope on Ubuntu 20.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install cscope Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install cscope using apt-get by running the following command:

sudo apt-get -y install cscope

Install cscope Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install cscope using apt by running the following command:

sudo apt -y install cscope

Install cscope Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install cscope using aptitude by running the following command:

sudo aptitude -y install cscope

How To Uninstall cscope on Ubuntu 20.04

To uninstall only the cscope package we can use the following command:

sudo apt-get remove cscope

Uninstall cscope And Its Dependencies

To uninstall cscope and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:

sudo apt-get -y autoremove cscope

Remove cscope Configurations and Data

To remove cscope configuration and data from Ubuntu 20.04 we can use the following command:

sudo apt-get -y purge cscope

Remove cscope configuration, data, and all of its dependencies

We can use the following command to remove cscope configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge cscope

References

Summary

In this tutorial we learn how to install cscope package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.