Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22151

Why does this makefile fails when I remove the vpath directive?

$
0
0

I am playing around with GNU GCC makefiles, and made this simple one to build a "Hello, world!" program.

CC=gcc
SOURCES=./Source/main.c
BUILD_DIR=./Build
TARGET=main

all: $(BUILD_DIR)/$(TARGET).exe

OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(SOURCES)))

$(BUILD_DIR)/%.o: %.c
    $(CC) -c $< -o $@

$(BUILD_DIR)/%.exe: $(OBJECTS)
    $(CC) $< -o $@

I cannot understand why when I remove or comment this line vpath %.c $(sort $(dir $(SOURCES))), make stops and returns this error:

> Executing task: D:\Servers\Compilers\MinGW\bin\mingw32-make.exe GCC_PATH=D:\Servers\Compilers\gcc-arm-none-eabi\bin <

mingw32-make: *** No rule to make target 'Build/main.exe', needed by 'all'.  Stop.

Could you please explain me why?


Viewing all articles
Browse latest Browse all 22151

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>