Jeremy Talus
Jeremy Talus

Reputation: 125

makefile Compile issue

I have some trouble with my makefile When I try to make I get the error:

no rule to make the target main.o

But I can't see my error, in fact it's a template Makefile that I have made few years ago, it's a cpp project.

(I have another error : /usr/bin/ld: can't find Sources/: file format not know, I think I made something wrong with the wildcard thing)

NAME = Pretorian

SRCDIR = ./Sources/
HDDIR = ./Include/

SRCS = $(SRCDIR)$(wildcard *.cpp)
OBJ = $(SRCS:.cpp=.o)

CC = g++

RM = rm -f
ECHO = echo -e

CFLAGS += -W -Wall -Werror -ansi -pedantic
HFLAGS = -I$(HDDIR)
LDFLAGS =

%.o: %.cpp
        $(CC) -o $@ -c $< $(CFLAGS)

$(NAME): $(OBJ)
        @$(CC) $(CFLAGS) $(HFLAGS) -o $(NAME) $^ $(LDFLAGS)
        @$(ECHO) '\033[0;32m> Compiled Without error\033[0m'

all: 
        $(NAME)

clean:
        $(RM) $(OBJ)
        @$(ECHO) '\033[0;33m> Directory cleaned\033[0m'

fclean: clean
        $(RM) $(NAME)
        @$(ECHO) '\033[0;33m> Remove executable\033[0m'

re: fclean all

Upvotes: 0

Views: 62

Answers (1)

DGKarlsson
DGKarlsson

Reputation: 1101

This seems to do the trick for me:

SRCS = $(wildcard $(SRCDIR)*.cpp)

Upvotes: 1

Related Questions