How to solve Qt Project ERROR: Cannot run compiler ‘g++’

Installation of Qt is now straightforward with the Qt setup. However, sometimes we might get the following error in Windows when creating a new project or opening an existing one. This article will discuss steps to resolve this error,

Project ERROR: Cannot run compiler 'g++'.

Let’s see the full error description :

The system cannot find the path specified.
Project ERROR: Cannot run compiler 'g++'. Output:
===================
# 1 "D:/dev/5.15.2/mingw81_64/mkspecs/features/data/macros.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "D:/dev/5.15.2/mingw81_64/mkspecs/features/data/macros.cpp"
QT_COMPILER_STDCXX = 201402L
# 26 "D:/dev/5.15.2/mingw81_64/mkspecs/features/data/macros.cpp"
QMAKE_GCC_MAJOR_VERSION = 8
QMAKE_GCC_MINOR_VERSION = 1
QMAKE_GCC_PATCH_VERSION = 0
===================
Maybe you forgot to setup the environment?

Follow the steps to resolve this error.

Check Mingw is properly installed

One of the possible reasons may be you missed installing MinGW so the g++ compiler is not available. So just uninstall the existing Qt installation and reinstall Qt.

You can download Qt setup from Qt’s official site.

Ensure MinGW 32-bit and 64-bit are checked as shown below.

Next, we need to ensure that MinGW 32-bit and 64-bit are checked in the “Developer and Designer Tools “section as shown below.

After the Qt installation, we need to check whether the issue is resolved. If not resolved then go to the next step.

Check the registry AutoRun entry

Ensure your PATH environment variable paths are valid.

Open the Windows registry editor by typing “regedit” in the Windows search bar. It will open Registry editor software.Check the following entry :

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor\AutoRun

or

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\AutoRun

Ensure the AutoRun value is blank as shown below, and save and close the registry editor.

This will resolve the “Project ERROR: Cannot run compiler ‘g++’ error.