9

When I run nmake.exe from make I get this error:

Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
Copyright (C) Microsoft Corporation.  All rights reserved.

NMAKE : fatal error U1065: invalid option '-'

But I'm not passing in '-' as an option anyplace.

If I run the same command from outside of make it works correctly.

docwhat
  • 11,435
  • 6
  • 55
  • 54

3 Answers3

11

The problem is that the environment variables MAKE and MAKEFLAGS are set by make. These are confusing nmake.exe.

To fix this, just prefix your call to nmake.exe with env -u MAKE -u MAKEFLAGS

Example:

 some-make-target:
      env -u MAKE -u MAKEFLAGS nmake.exe /a /l
docwhat
  • 11,435
  • 6
  • 55
  • 54
  • 1
    What is this `env` command? It doesn't seem to be a standard cmd command. Are you using another shell for Make on Windows? – Wolfgang Ulmer Oct 20 '15 at 12:50
  • 1
    It isn't a windows tool. It's a unix tool that I was using. I'm not sure what the equivalent Windows command would be. `env -u MAKE -u MAKEFLAGS` is unsetting `MAKE` and `MAKEFLAGS` environment variables for that one command only. – docwhat Oct 21 '15 at 17:45
1

Supposing you are on a windows prompt command, and you have a rule like that:

 target:
   cd ... && nmake.exe ...

by

 target:
   cd ... && set MAKEFLAGS= && nmake.exe ...

set FOO: display the value of FOO if exist, (like echo %FOO%)

set FOO=: unset FOO, (i.e. later call to set FOO will display Environment variable FOO not defined)

note: there is no unset command

Mizux
  • 8,222
  • 7
  • 32
  • 48
0

if you use windows, simply go to Enviroment Variables in advance system setting and delete system variables "MAKEFLAGS". It should not confuse Nmake anymore.