Skip to content

Error /usr/bin/ld "undefined reference to" Makefile in linux #31

Answered by davilanxon
davilanxon asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone who have problems compiling in linux, this makefile works:

NAME	= so_long

LIBMLX = lib/MLX42/libmlx42.a

LIBFT = lib/libft/libft.a

SRCS	= src/so_long.c

OBJS	= $(SRCS:.c=.o)

CC	= gcc

RM	= rm -f

CFLAGS	= -Wall -Wextra -Werror -Iincludes -g

MLX_FLAGS = -ldl -lglfw

all: $(NAME)

$(NAME):	$(OBJS)
			make -C lib/MLX42/ all
			make -C lib/libft/ all
			$(CC) $(CFLAGS) $(OBJS) $(LIBFT) $(LIBMLX) $(MLX_FLAGS) -o $(NAME) 


clean: 
		$(RM) $(OBJS)
		make -C lib/MLX42/ clean
		make -C lib/libft/ clean

fclean: clean
		$(RM) $(NAME)
		make -C lib/MLX42/ fclean
		make -C lib/libft/ fclean

re:	fclean all

.PHONY:	all clean fclean re

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@W2Wizard
Comment options

Answer selected by davilanxon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Question Further information is requested
2 participants