momo coder
momo coder

Reputation: 151

CLion makefile error : Error running 'Makefile': Cannot run program "\usr\bin\make" CreateProcess error=2, The system cannot find the file specified

Running Makefile in CLion. The Makefile is of stockfish(chess) and is here https://github.com/official-stockfish/Stockfish/blob/master/src/Makefile

I am trying this on a windows 10 system. Why is make unable to find the file? Is it a the separator issue of \ vs / on linux vs windows?

Full error

Error running 'Makefile': Cannot run program "\usr\bin\make" (in directory "C:\Users\anmol\Desktop\Coding\stockfish\src"): CreateProcess error=2, The system cannot find the file specified

My version of CLion has makefile support inbuilt and I have toolchain compilers installed via cygwin.

Upvotes: 11

Views: 16174

Answers (3)

vitams
vitams

Reputation: 645

Remove full path because in Powershell its work so

image

Upvotes: 0

Bass
Bass

Reputation: 5338

The full explanation of your problem is given in this comment in the JetBrains bug tracking system.

The Cannot run program "\usr\bin\make" error originates from the Makefile language plug-in which comes bundled with CLion and can be added to other JetBrains' IDEs, too. Despite being bundled, the plug-in was originally a 3rd-party one and is not a part of Makefile support in CLion: to some extent, it complements the built-in support for Makefile projects (e. g.: by enabling syntax highlighting), but has some functionality orthogonal to that.

That "orthogonal" functionality is, particularly, the way the plug-in runs Make (when you click the gutter icon from the Makefile editor). This has nothing to do with Toolchains in CLion and needs to be configured separately.

Cygwin

enter image description here

MinGW

enter image description here

You'll need to type the full Windows path into the text field (e. g.: C:\cygwin64\bin\make.exe) and either check the Use Cygwin box (for Cygwin) or leave it unchecked (for MinGW).

WSL

As of version 2022.1, the plug-in also supports running Make inside WSL guest VMs. See this section in the official documentation for more details.

Following the above guidelines will enable you to invoke Make targets from the Makefile editor (using any JetBrains IDE with the plug-in installed, not just CLion).

Upvotes: 16

user2534096
user2534096

Reputation:

Workaround:

In a CLion Makefile project, two "Configuration" types are available: "Makefile Target" and "Makefile Application". If you edit a "Makefile Application" configuration, you will see a field called "Executable: "

The "Executable: " can be any Linux command including make itself. For "Makefile Application" (not "Makefile Target") the command is properly initiated using wsl.exe so that the command is run in WSL and not Windows.

(The problem with "Makefile Target" is obviously a CLion/plugin bug whereby "\usr\bin\make" is not run using wsl.exe, so it's run in Windows, so Windows is saying that it can't find it, which is expected because it's not supposed to be run in Windows to begin with! :-) )

Upvotes: 2

Related Questions