我做错了什么?您能否发送一些有用的链接,让我的 makefile 工作更轻松、更好?
get_next_line.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
Makefile:27: recipe for target 'gnl' failed
make: *** [gnl] Error 1
Run Code Online (Sandbox Code Playgroud)
+++
SRC = gnl.c
OBJ = $(SRC:.c=.o)
INCLUDES = gnl.h
NAME = gnl
CFLAGS = -Wall -Werror -Wextra
CC = gcc
DIR = LIBFT
%.o: %.c $(SRC) $(INCLUDES)
$(CC) $(CFLAGS) -c $<
all: $(NAME)
$(NAME): $(OBJ)
make -C $(DIR)
$(CC) $(CFLAGS) -o $(NAME) $(OBJ) -L. $(DIR)/libft.a
clean:
make clean -C $(DIR)
rm -f $(OBJ)
fclean:
make fclean -C $(DIR)
rm -f $(NAME)
re: fclean all
Run Code Online (Sandbox Code Playgroud)
这make本身并不是错误。它说
get_next_line.o: file not recognized: File format not recognized
Run Code Online (Sandbox Code Playgroud)
所以这就是你的问题。不知何故,您设法.o在您的目录中有一个已损坏的文件。删除它,事情会变得更好。