#Makefile
61 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.
should I create main.c for compile a library file?
I changed the error.
@vague panther
last error was about my turkish keyboard mistake
looks like $(SRC) is missing ft.putchar.c
can you echo print it to verify that its missing ?
@agile parrot
i was talking about your makefile
but makefile trying to compile it in not obj it's trying to use it in obj/libft
CFLAGS= -Wall -Wextra -Werror
SRC=src/
LIBFT=$(SRC)libft/
PRINTF=$(SRC)printf/
LIBFTH=$(LIBFT)libft.h
PRINTFH=$(PRINTF)printf.h
HEADERS=$(PRINTF), $(LIBFTH)
SRCS=$(wildcard $(LIBFT)*.c),$(wildcard $(PRINTF)*.c)
OBJ=obj/
OBJS=$(patsubst $(SRC)%.c, $(OBJ)%.o, $(SRCS))
OBJ_PRE=$(addprefix $(OBJ), $(OBJS))
OUTPUT = printf.a
$(OBJ)%.o : $(SRC)%.c $(HEADERS)
@mkdir -p obj
@echo "Compiling: $<"
$(CC) $(CCFLAGS) -c $< -o $@
$(OUTPUT): $(OBJS)
@ar rcs $(NAME) $(OBJ_PRE)
@echo "Printf Done !"
lib: $(OUTPUT)
all: lib
clean:
$(RM) -r $(OBJ)
here is the code btw
create a rule:
print:
@echo "SRC: " $(SRC)
...
and print all the variables you have
and then show me the output of make print
the ... is an ellipsis
You are missing a compilation definition for your sources in the root folder, as your rule explicitly mentions $(SRC)%.c
you should put the rest of the variables instead of the ...
which veriable I should put there
CC=gcc
CFLAGS= -Wall -Wextra -Werror
SRC=src/
LIBFT=$(SRC)libft/
PRINTF=$(SRC)printf/
LIBFTH=$(LIBFT)libft.h
PRINTFH=$(PRINTF)printf.h
HEADERS=$(PRINTF), $(LIBFTH)
SRCS=$(wildcard $(LIBFT)*.c),$(wildcard $(PRINTF)*.c)
OBJ=obj/
OBJS=$(patsubst $(SRC)%.c, $(OBJ)%.o, $(SRCS))
OBJ_PRE=$(addprefix $(OBJ), $(OBJS))
OUTPUT = printf.a
I couldn't understand what you mean
I still can't understand. that is beginning my code right?
there is a lot of variable 😄
$(OBJS): $(SRCS) $(HEADERS)
@mkdir -p obj
@echo "Compiling: $<"
$(CC) $(CCFLAGS) -c $< -o $@
try this
OBJS also looks wrong
do you understand what i mean with this ?
SRC is src folder
print:
@echo "SRC: " $(SRC)
@echo "SRCS: " $(SRCS)
@echo .................
do that with every variable
i cant help you if i dont know whats inside the variables
there is two folder
libft and printf
these are two different library
in this folders have two header files too
libft.h and printf.h
for example
src/printf/printf.h
src/printf/printf.c
src/libft/libft.h
src/libft/libft.c
these are my files
and I need one file name is "printf.a"
and when I want to use all this functions I will compile my main.c with just printf.a file
like gcc main.c printf.a
@vague panther
I can’t see that you have added main.c and ft_print.c to your SRCS variable as they don’t appear to be in the src/ directory. Maybe move them there, change your includes in them and try the makefile again
