#Makefile

61 messages · Page 1 of 1 (latest)

agile parrot
#

I got problem this makefile. I don't have any compile process in the main folder but I got an error about main.c which is located in main folder. Anyone know how can I fix this makefile?

fast heraldBOT
#

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.

vague panther
#

well

#

as it tells you

#

the rule to make main.c is missing

agile parrot
vague panther
agile parrot
#

I changed the error.

#

@vague panther

#

last error was about my turkish keyboard mistake

vague panther
#

looks like $(SRC) is missing ft.putchar.c

#

can you echo print it to verify that its missing ?

#

@agile parrot

agile parrot
#

it's there you can see it

vague panther
#

i was talking about your makefile

agile parrot
#

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

vague panther
#

create a rule:

print:
    @echo "SRC: " $(SRC)
    ...

and print all the variables you have

#

and then show me the output of make print

agile parrot
#

when I delete "..."

vague panther
#

the ... is an ellipsis

dense escarp
#

You are missing a compilation definition for your sources in the root folder, as your rule explicitly mentions $(SRC)%.c

vague panther
#

you should put the rest of the variables instead of the ...

agile parrot
vague panther
#
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
agile parrot
agile parrot
vague panther
#
print:
    @echo "SRC: " $(SRC)
agile parrot
#

there is a lot of variable 😄

vague panther
#

make print

#

and show me the output

#

jesus christ

agile parrot
#

I did it allready

vague panther
#
$(OBJS): $(SRCS) $(HEADERS)
    @mkdir -p obj
    @echo "Compiling: $<"
    $(CC) $(CCFLAGS) -c $< -o $@

try this

#

OBJS also looks wrong

agile parrot
#

missing seperator

vague panther
agile parrot
#

SRC is src folder

vague panther
#
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

agile parrot
#

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

agile parrot
#

@vague panther

dense escarp
#

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