Windows make throws an error when I try to use "if EXIST"

Danila

I am using make version 4.2.1 on windows. I have a very simple make file:

some_target:
        if EXIST C:\ echo hi

However, when I run the following command:

"..\env\build_tools\make\make.exe" -f "make.mk" -j16 some_target

I get the following error:

/usr/bin/sh: -c: line 3: syntax error: unexpected end of file
make: *** [make.mk: some_target] Error 2

When I run the same recipe line in a regular command prompt it executes perfectly fine and doesn't throw any errors. What is happening here? It's also weird because if I put the source code and makefile in an eclipse project and configure the build correctly, it runs perfectly fine.

MadScientist

This is not that mysterious; the answer is in the output you posted here:

/usr/bin/sh: -c: line 3: syntax error: unexpected end of file

This means that the command you told make to run was given to /usr/bin/sh, which is a POSIX shell. But the command you wanted to run:

    if EXIST C:\ echo hi

is a Windows cmd.exe shell command. That cannot work. Try starting a Git Bash shell for example and typing the above command into it: you'll get the same error. If you want your makefile to always use cmd.exe as its shell you have to add that to your makefile:

SHELL := cmd.exe

should do it I think (I don't really do Windows). The make program was created back in the 1970's on UNIX systems and so it's fundamentally a POSIX program and it prefers to run using POSIX tools; if you don't specify which shell to use then the Windows port will first look for a POSIX shell and if one is found it will use that; if it's not found it will fall back to cmd.exe.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Mismatch Exception Error when I try to use nextint() for File IO

I have a view that runs fine when executed, but when I try to open it in design mode, it throws a parsing error

Google Speech Recognition module throws error when I try it out

Import error when I try use "requests" module

PyMongo NoneType error when I try to use None as null for query

Can I make use of multiple try catch blocks to throws multiple errors or exceptions

Function name not defined error when i try to use recursion

When i try to make a notification with winrt, it makes an error

I get an Error when I try to use Firebase Auth

Make file error when I try to do with linking the test file

When I try to use scanf with 2 arrays I get an error

Proguard return an error when I try to use it in Eclipse

Bank Program error when I try to access an account that does not exist

My program throws an error when I try to run it on Linux (works fine on windows)

Why is this error showing when I try to use javaws?

PyCharm throwing an error when I try to use macports python

When i try to use method it give error

"Variable does not exist" when I'm try to make a query with Ecto

Error: use of deleted function when I try to use a reference

getting this error when i try to use the elif key word please

When I try to use firebase in my flutter app it produces an error

Flutter throws an error when i use Text field with auto focus

Gcc throws error when I try to compile the test folder in libburn

Error when i try to use select 2 in rails 6

Lua: I get error when I try to run a script in Windows

getting error when I try to use Drivers in CodeIgniter

Jackson throws error mapping exception when I try to deserialize a list of objects

When I try to declare a global variable it throws the error Statement expected

Incorrect use of ParentDataWidget when I try to make a drawer menu