What is m4 and How to Fix: “m4: command not found” error

If you have installed fresh Ubuntu on your development machine and tried to compile some opensource source code which uses “autoconf” for generating Makefile for compilation, its highly possible that you may see an error as below,

/bin/bash: m4: command not found

what is m4 ?

GNU ‘m4’ is an implementation of the traditional UNIX macro processor.

‘m4’ is a macro processor, in the sense that it copies its input to the output, expanding macros as it goes. Macros are either builtin or user-defined, and can take any number of arguments. Besides just doing macro expansion, ‘m4’ has builtin functions for including named files, running shell commands, doing integer arithmetic, manipulating text in various ways, performing recursion, etc…. ‘m4’ can be used either as a front-end to a compiler, or as a macro processor in its own right.

Autoconf needs GNU ‘m4’ for generating ‘configure’ scripts, but not for running them.

How to resolve error “m4: command not found” ?

$ sudo apt-get install m4 
Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question