[英]Makefile… creating a static library
please can somebody help me with this makefile... What is wrong with this ? 请有人可以帮我解决这个makefile问题吗?
NAME = libft.a
SRCS = ft_memccpy.c ft_putnbr.c ft_strequ.c ft_strnequ.c \
ft_memchr.c ft_putnbr_fd.c ft_striter.c ft_strnew.c \
ft_memcmp.c ft_putstr.c ft_striteri.c ft_strnstr.c \
ft_atoi.c ft_memcpy.c ft_putstr_fd.c ft_strjoin.c ft_strrchr.c\
ft_bzero.c ft_memdel.c ft_strcat.c ft_strlcat.c ft_strstr.c \
ft_isalnum.c ft_memmove.c ft_strchr.c ft_strlen.c ft_strsub.c \
ft_isalpha.c ft_memset.c ft_strclr.c ft_strmap.c ft_strtrim.c \
ft_isascii.c ft_putchar.c ft_strcmp.c ft_strmapi.c ft_tolower.c \
ft_isdigit.c ft_putchar_fd.c ft_strcpy.c ft_strncat.c ft_toupper.c \
ft_isprint.c ft_putendl.c ft_strdel.c ft_strncmp.c \
ft_memalloc.c ft_putendl_fd.c ft_strdup.c ft_strncpy.c \
OBJ = $(SRCS:.c=.o)
all: $(NAME)
$(NAME):
gcc -c -Wall -Wextra -Werror $(SRCS)
ar rc $(NAME) $(OBJ)
ranlib $(NAME)
clean:
bin/rm -f *.o
fclean: clean
bin/rm -f libft.a
re: fclean all
I still get this error : Makefile:14: *** Recursive variable `SRCS' references itself (eventually). 我仍然收到此错误:Makefile:14:***递归变量`SRCS'引用了自己(最终)。 Stop. 停止。 How can I make it work? 我该如何运作?
The problem is that you have a stray line continuation escape at the end of the values being assigned to your SRCS
variable. 问题在于,在分配给SRCS
变量的值的末尾有一个杂散的行连续转义SRCS
。
make sees this line at then end 使看到这条线然后结束
ft_memalloc.c ft_putendl_fd.c ft_strdup.c ft_strncpy.c \
and thinks it needs to include the next line in the value of SRCS
too. 并且认为它也需要在SRCS
的值中包括下一行。
Only the next line is OBJ = $(SRCS:.c=.o)
which references $(SRCS)
and creates the loop that make is complaining about. 只有下一行是OBJ = $(SRCS:.c=.o)
,它引用$(SRCS)
并创建make抱怨的循环。
Either remove that stray backslash or add a blank line between those two lines. 删除该反斜杠或在这两行之间添加空白行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.