1

I was given a Windows makefile to use for an OpenGL assignment I have to do, but it throws this error when I run it using 'NMake':

makefile(7) : fatal error U1000: syntax error: ')' missing in macro invocation

This is the content of the makefile they gave me:

CXX=cl
COMMONFLAGS= -nologo
CXXFLAGS= -MD -c
INCLUDES= -Iinclude
LFLAGS= -incremental:no -manifest:no OpenGl32.lib glew32.lib SDL2.lib SDL2main.lib -SUBSYSTEM:CONSOLE
BUILDDIR=build
SRCDIR=src
SRC=$(wildcard $(SRCDIR)/*.cpp)
_OBJ=$(SRC:.cpp=.obj)
OBJ=$(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(_OBJ))
TARGET=prac1.exe
TARGETPATH=$(BUILDDIR)/$(TARGET)

build: $(OBJ) $(TARGET)

run:
    cd $(BUILDDIR); ./$(TARGET)

$(TARGET): $(OBJ)
    $(CXX) $(OBJ) -Fe$(TARGETPATH) $(COMMONFLAGS) -link $(LFLAGS)


$(BUILDDIR)/%.obj: $(SRCDIR)/%.cpp
    $(CXX) $(INCLUDES) $(CXXFLAGS) $< -Fo$@ $(COMMONFLAGS)

clean:
    rm -f $(TARGETPATH)
    rm -f $(OBJ)

How can I fix it? Many thanks!

Matt Young
  • 73
  • 2
  • 12
  • What is your question exactly? – iehrlich May 26 '17 at 20:44
  • @iehrlich How can I fix this error? – Matt Young May 26 '17 at 20:45
  • is it the complete makefile? – iehrlich May 26 '17 at 20:51
  • @iehrlich Yes, it is – Matt Young May 26 '17 at 20:53
  • 1
    Look closely at line 7. And compare it to [the documentation of the error message](https://msdn.microsoft.com/en-us/library/ee479505(v=winembedded.70).aspx): "Indicates that a left parenthesis, "(", appeared without a matching right parenthesis, ")", in a macro invocation. **The correct form is $(name); $n is allowed for one-character names**." – Raymond Chen May 26 '17 at 20:57
  • @RaymondChen could you please elaborate? – iehrlich May 26 '17 at 21:01
  • The error says that there's a problem on line 7, so you should focus on line 7: `SRC=$(wildcard $(SRCDIR)/*.cpp)`. Next, notice that the error message says what the correct form of a macro is. Finally, observe that line 7 does not follow the correct form. – Raymond Chen May 27 '17 at 00:43

1 Answers1

0

As far as I can tell, this is not an NMake makefile, but a GNU Make makefile. Also, there's no 'rm' command in Windows. It seems like someone took a *nix makefile and semi-brewed it for Windows build...

What makes me think so is primarily the presence of wildcard and patsubst functions (which are not supported by NMake AFAIK), the rm command for remove, and *nix-style paths.

iehrlich
  • 3,572
  • 4
  • 34
  • 43
  • How do I go about fixing it? – Matt Young May 26 '17 at 21:07
  • Simple enough, you write it. Or you ask the one who gave it to you how are you intended to run it. Or, if you just need to get this up and running, you might consider creating a simple solution with VC++ express (which might be downloaded freely). There are actually plenty of options. – iehrlich May 26 '17 at 21:11