How to Install and Use make on Ubuntu 22.04


The make command line utility builds and manages the packages/applications equipped with the source code. The source code is compiled automatically and a final executable is generated using the make command.

The make command reads the instructions from the MakeFile and acts accordingly. The rules in the MakeFile are categorized into three parts:

  • Targets: Files to be updated/created.
  • Dependencies: Files that help achieve the targets.
  • Commands: Upon the change of dependencies, these commands ask the make utility to create/update the target.

On Ubuntu 22.04, various tools are available through the source code. To get them on your system, make utility must be there. This post will address the method to install and how it compiles/builds the source code on Ubuntu 22.04.

How to Install make on Ubuntu 22.04

Normally, the make command is pre-installed on your Ubuntu 22.04. However, if you have chosen the minimal installation, then you have to install it, and here is the process to do so:

Step 1: Update the Core Libraries

To get the latest available make, update the packages list/index:

sudo apt update

Step 2: Install make

To install make, run the command:

sudo apt install make

Step 3: Verification (Version and Executable)

Check the make version and also verify the executable’s location using the which command:

make --version
which make

Version 4.3 is installed with its executable placed at “/usr/bin/make”.

Alternative: Install Build-Essential

Alternatively, you can get the build-essential toolkit which offers make and additional tools (set of compilers and their libraries) required for building source code:

sudo apt install build-essential

It also installs the same version of make (as of Step 2).

How to Use make on Ubuntu 22.04

The make utility compiles the source code-based program and builds the final executable. In short, it assists in converting the code-based program to an executable. The following is the execution flow to use the make command:

Prerequisite Step: Ensure the Libraries/Essentials

Before executing the make command, you need to ensure the essential libraries/packages are present on the system for compilation. The libraries/packages check is carried out using the “configure” script. To avoid any errors, ensure you have run the configure script before using make. The configure script is available in the extracted directory and is run as:

./configure

Note: The “configure” script also creates a custom MakeFile as per your system.

From now onwards, the make command comes into practice.

Step 1: Build the Source Code and Convert it Into a Finished Program

When the MakeFile is modified, the make command accesses it and follows the instructions in it. Based on these instructions, the make command builds a final program. The make command is used where the configure script is run (where the MakeFile is available). Let’s check how it is used/executed.

You need a “make” keyword to use make, as shown below:

make

  • Tip: Accelerate the Build Process

Sometimes, the source code is complex and make command has to do tens of jobs which takes a lot of time. In such a case, you can use the“-j” flag and define the number of jobs to be run simultaneously. However, it depends on the cores of your processor. For instance, to run 4 jobs, your system must have 4 cores to handle the jobs simultaneously.

make -j4

Step 2: Install the Software

After building, now is the time to move/shift all the files to the system-defined directories. For instance, the program executable needs to be placed at “/usr/bin/”. Similarly, the manual or any other program file required to run the program will be placed at the appropriate location. To do so, the make command is used with the install keyword as:

make install

That’s how you can use the make command to build the program/software driven from the source code.

Uninstall a make Based Program

If you have installed a program using the make functionality and want to uninstall it, then you have to run the “uninstall” script (inside the directory where you have run make and make install):

make uninstall

In certain cases, you might not get the uninstall script, then you need to manually remove the directories/files associated with that installation.

How to Fix “make: *** No targets specified and no makefile found. Stop.” Error

While using the “make” command to build the package, you might get the “make: *** No targets specified and no makefile found. Stop”. The error looks like this, as shown below:

Let’s discuss the reason for this error:

Reason: MakeFile Not Available

The make command is unable to read the MakeFile to carry out the building process. There are two possibilities:

  • The configure script is not run before the make command.
  • The configure script is executed but it shows some missing prerequisites (usually compilers) necessary for the configure script.

Let’s see how it can be solved:

Solution: Install Prerequisites and Run the Configure Script

To get rid of this error, you have to check for the prerequisites, configure the source code (after ensuing the required libraries/compilers), and then make/build the program. Let’s learn how all these work:

Step 1: Install Prerequisites for Configuration

First, install the latest set of compilation/building tools, (build-essential on Ubuntu):

sudo apt install build-essential

Step 2: Run the Configure Script

Once done, run the configure script (in the extracted directory) and make sure that no error arises while executing the “configure” script:

./configure

Note: If any error occurs (some missing libraries that vary from package to package), you must install the missing dependencies manually.

Step 3: Use the make/make install

When all set, use the make and make install commands to complete the building process.

make
make install

That’s how effectively you can use make.

Bottom Line

The make command compiles the program automatically and then converts it into the system-supported executable. To install make on Ubuntu 22.04, use the command “sudo apt install make”. Moreover, you can also install make and other build-essentials using the “sudo apt install build-essential‘.

This post has demonstrated the methods to install make on Ubuntu 22.04 alongside its detailed usage and troubleshooting

Print Friendly, PDF & Email
Categories