1

I'm running Windows 10 and am trying to write a Makefile to compile a C++ file that uses the SFML library as well as the nuklear libraries. I have MinGW installed and added to my PATH, and I also have GNU Make installed and added to my PATH. So I can call both make and gcc from a Command Prompt window.

The Makefile I'm editing is:

# Install
CC = gcc
BIN = demo

# Flags
CFLAGS += -s -O2

SRC = main.cpp
OBJ = $(SRC:.cpp=.o)

# Edit the line below to point to your SFML folder on Windows
SFML_DIR = C:/SFML-2.5.1/

BIN := $(BIN).exe
LIBS = -lmingw32 -DSFML_STATIC -lsfml-window-s -lsfml-system-s -lopengl32 -lwinmm -lgdi32

SFML_INC = -I $(SFML_DIR)/include
SFML_LIB = -L $(SFML_DIR)/lib

$(BIN):
    $(CC) $(SRC) $(CFLAGS) -o $(BIN) $(SFML_INC) $(SFML_LIB) $(LIBS)

But as per the nuklear documentation, I need to include nuklear.h in the Makefile. For my project, I have a directory called include which contains nuklear.h. The full path is similar to:

C:/Users/Me/Github Repositories/folder-1/folder-2/include/

So I make the following additions to the Makefile:

SFML_DIR = C:/SFML-2.5.1/
INCL_DIR = C:/Users/Me/Github Repositories/folder-1/folder-2/include/

$(BIN):
    # $(CC) $(SRC) $(CFLAGS) -o $(BIN) $(SFML_INC) $(SFML_LIB) $(LIBS)
    $(CC) $(SRC) $(CFLAGS) -o $(BIN) -I $(INCL_DIR) $(SFML_INC) $(SFML_LIB) $(LIBS)

I added the path to nuklear.h and have asked included it in compilation by specifying the -I flag. But I get the following error when I run Make:

makefile:23: *** missing separator.  Stop.

Now, there's a space in the path ("Github Reposities"). So I believe I need to add quotation marks to include the full path.

But when I add quotation marks to the full path, I get the following error:

make: *** No rule to make target `/Users/Me/Github', needed by `demo.exe'.  Stop.

So I'm missing something when it comes to specifying paths in a Makefile on Windows. How can I add a complete path in my Makefile when the path contains spaces?

Alureon
  • 179
  • 1
  • 3
  • 14
  • I don’t see how your errors arise from that makefile, but does this answer your question? [Can GNU make handle filenames with spaces?](https://stackoverflow.com/questions/9838384/can-gnu-make-handle-filenames-with-spaces) – Davis Herring Mar 14 '20 at 02:49

1 Answers1

0

I fixed the problem.

Firstly, I moved my project out of the Github Repositories directory and into a new directory with no spaces, GitHub_Repositories. That fixed the path issue.

Secondly, I had to insert a tab, not a space, before

$(CC) $(SRC) $(CFLAGS) -o $(BIN) $(SFML_INC) $(SFML_LIB) $(LIBS)

Previously (as one can see in the original post), there were spaces there.

Alureon
  • 179
  • 1
  • 3
  • 14
  • There is no issue with paths containing whitespace _in recipes_. Make doesn't care about that: you just have to be sure you escape the spaces correctly for your shell. What make doesn't like is whitespace in targets or prerequisites in the makefile. – MadScientist Mar 14 '20 at 18:35
  • But of course you must use a hard TAB to indent recipes. You cannot use spaces. – MadScientist Mar 14 '20 at 18:35