Linux Commands

Fix Make Command Not Found Error on Ubuntu

Nowadays, we have evolved at a stupendous rate when it comes to technology and digitization. Almost every task which would have been a hassle is a click away due to modern technology. We can build applications through easy-to-use tools that save us time and facilitate day-to-day life.

But what if we are faced with a situation where we don’t have these tools, or maybe we need to build an application from scratch or tweak certain aspects of it? Linux distributions answer this question by presenting an important command in the Linux arsenal, the ‘make’ command.

Make command is one of the most widely used commands on Linux distributions, which offers a pathway to download polished versions of the developer’s tools on your system. However, its pivotal role lies in building or compiling entire programs via source code. ‘Make’ is a command which is generally used to build dependencies like executable files or libraries using a source code. It may be generally referred to as a command that transforms some code into something tangible that can be used and regarded as desired result or a part of it.

This command works on a basic level, from compiling source files to object files, which in turn gives us executable files for various programs we run.

Working of the Make command

Make command assumes command-line arguments passed to it from the targets. The detailed info of these targets is contained in the ‘makefile’. Makefile is synonymous with a data ledger containing targets and actions to be performed on these targets. The ‘makefile’ is the first file that is scanned whenever the make command is executed.

The make file contains all dependencies and a list of actions to perform. If these dependencies are the required targets, the makefile scans targets and develops their repositories, which are transferred to make commands for the compiling process. Even if we modify a select number of source files, executing the make command afterward compiles the object files relating to the modified source file, thereby saving time and resources.

It should be noted that the make command has various arguments, as stated above. Not including the arguments may result in the building of the first target that is seen by its makefile. This target is usually “all”.

Make: command not found remedy

Make is an important command, so it comes pre-loaded in many Linux distros. However, sometimes it needs to be downloaded or throws an error for “command not found”.

We go through the steps to check and resolve the issue centered around making a command in the following steps.

First and foremost, we check whether make is even present on our system. To verify, we use the ls function to examine the content of /usr/bin/make directory.

$ ls /usr/bin/make

$ /usr/bin/make --version

Using the aforementioned, we can check its version using.

In case we don’t have a make command on your system, we can easily install it by issuing the following commands.

$ sudo apt install make

This command will most probably work if one uses Ubuntu 18.04 or later. In case it does not, or we are on an older version, we can use the indirect method of downloading the build-essential package by typing in.

$ sudo apt install build-essential

This package contains all necessary files related to file compilation and building. Make is a part of this package, so we will also have installed the make command.

In case we have broken packages or your make command issues errors, we can always uninstall and reinstall afterward for a stable restart. This may resolve your problem.

Reinstall using.

$ sudo dpkg-reconfigure make

Syntax

General syntax of make command is.

$ make [ -f makefile][options][target(s)]

Flags with make: Make command comes with several flags that dictate how the files to compile will be handled. These flags are briefly described below.

  • -b: This is mostly an ignored option but may be included in certain versions of making.
  • -B: This option dictates that all targets e implemented with the make and therefore compiled.
  • -C dir: This option states the system to change directory to dir before implementing the make command.
  • -d: This is an elaborate option that allows the user to view how make is compiling the files. This option deals with debugging as it displays complete info of the file under operation and how it is being processed.
  • –debug[=FLAGS]: This option does the same job as the previous one, which is debugging. However, here, we may add flags like a for all debugging output, m for debugging while remaking make files, v for verbose basic debugging, and many more. These flags and their details can be found on the make command man page.
  • -f file: This is an important option that is generally included in the make file process. It points to the “file” specified and performs the make operation on it. It may be written as –makefile=file.
  • -e: This is an override option that enables precedence of environment variables over the makefile variables.
  • -i: This option enables make to ignore all errors.
  • -j[jobs]: This option specifies the jobs(commands) to be performed simultaneously.
  • -k: This option directs make command to keep going. For instance, error as made in target, the make command continues regardless and processes the other dependencies of the target without error correction.
  • -l[load]: This command specifies that no new jobs/commands be initiated in case there are previous jobs under processing. If no argument is provided, the previous load limit is removed.
  • -n, –just-print: option enables command printing without execution.
  • -o file: assumes the given file is old and its rules are ignored.
  • -p: prints database and version by reading the makefiles.
  • -q: returns binary values; 0 for up to date targets, non zero otherwise.
  • -R: Dictates make command not to define any built-in variables.
  • -S: counters k option and stops operation from keeping ongoing.
  • -s: This is the silent operation; it won’t print commands as they are executed and keeps processing backend.
  • -t: touch files, as in mark them up to date without any execution whatsoever.
  • -v: Displays version of display command.
  • -w: A useful option when one has to keep check of errors. This option prints messages after processing the file.
  • –no-print-directory: Undoes the operation of the –w option.
  • –warn-unidentified-variables: Warn in case an undefined variable is referenced.

Most options have been covered here; in case you wish for an updated list with a detailed explanation, head over to make commands manpage here.

Conclusion

This article went over the working of make, a necessary command with basic yet powerful applications. We explored various options to fix issues encountered with its implementation. Moreover, we went over its detailed work. We hope our article helped resolve your queries and fix any issues you have encountered.

About the author

Zeeman Memon

Hi there! I'm a Software Engineer who loves to write about tech. You can reach out to me on LinkedIn.