0
votes

I installed the base package to compile C++ with MinGW Installer GUI and CMake. I created a simple file .c with hello world, and can use cmake . -G"MSYS Makefiles" normally. I added E:\Programmation\MinGW\bin and E:\Programmation\MinGW\msys\1.0\bin to my path.

Here is my CMakeLists.txt:

cmake_minimum_required (VERSION 3.3)

project (Prototype)

set (EXECUTABLE_OUTPUT_PATH bin/${CMAKE_BUILD_TYPE})

file (
        GLOB_RECURSE

        source_files

        src/*
)

add_executable (
    my_exe 

    ${source_files}
)

Once the makefile is created however, when I use make I'll get the following error:

/bin/sh:/e/Users/MyName/Documents/GitHub/ProjectName/prototype/c/E:/Programmation/MinGW/msys/1.0/bin/make.exe: No such file or directory
make.exe": *** [all] Error 127

I can compile the file main.c just fine with gcc main.c and the exe it produces works, so the problem is with the make.exe.

If I use it in the msys.bat shell, located in E:\Programmation\MinGW\msys\1.0, it works as it should. So my guess is that the problem is with Powershell and the path. I'm thinking maybe it's because of the way hard drives are designated, since in the error I get it calls my E:\ disk /e/ first then E:/. When I work in msys.bat I have to write it this way: /e/Users/MyName...

2

2 Answers

3
votes

This is PEBKAC. The problem is not with make.exe, but rather, in the way you are attempting to misuse it.

How many times must I say this? Using MSYS make.exe, (or indeed any of the MSYS tools), in any environment other that the MSYS shell, which is started by running msys.bat, is definitively unsupported by the MSYS Project maintainers.

Since you say you problem goes away, when you use make.exe as you are supposed to, (in the MSYS shell, invoked by running msys.bat), this is your problem, and your problem alone. It apparently does not work, when you attempt to use it improperly, (i.e. from PowerShell): that's tough luck; when you break free software, by misusing it, you get to keep all the pieces.

0
votes

Contrary to the accepted answer, it is actually possible to do this using PowerShell:

sh.exe -c "cd ""$pathToMake""; make"

Make sure you sanitise backslashes for the shell before the call above.

$pathToMake = $pathToMake -replace "\\", "/"

Also the MSYS bin has to be in your path, which would typically look like this (your path maybe different):

$env:Path = "C:\GNUstep\msys\1.0\bin;$($env:Path)"