简体   繁体   中英

Makefile giving error with No target for rule G++

Complete Makefile noob here. I cannot figure out why this is happening, but I think it is whitespace/tab. I have this Makefile:

BUILD_DIR = build/debug
CC = g++
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
OBJ_NAME = play
INCLUDE_PATHS = -Iinclude
LIBRARY_PATHS = -Llib
COMPILER_FLAGS = -std=c++11 -Wall -O0 -g
LINKER_FLAGS = -lsdl2

all: $(CC) $(COMPILER_FLAGS) $(LINKER_FLAGS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(SRC_FILES) -o $(BUILD_DIR)/$(OBJ_NAME)

and it gives this error: make: *** No rule to make target `g++', needed by `all'. Stop. make: *** No rule to make target `g++', needed by `all'. Stop.

If I move the string to the bottom with tab and just use all: on one line and the string on the other it gives this:

Makefile:12: *** missing separator. Stop.

And I thought Python was crazy about space. Cannot figure out what I am doing wrong.

You need to put commands on a new line:

all:
    $(CC) $(COMPILER_FLAGS) $(LINKER_FLAGS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(SRC_FILES) -o $(BUILD_DIR)/$(OBJ_NAME)

and make sure it is indented with tab, not space

It is also not python, it's make

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM