1

this is my structure of my project

root
  |____Makefile
  |
  |___src
  |     |____*.c 
  |
  |___inc
  |      |___*.h
  |
  |___obj

The problem is that when i try to make i got this error

------->Building Wolf1 ...

Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Wolf1] Error 1

RM              = rm -rf
SDL              = libsdl2.a
TTF              = libsdl2_ttf.a
FT              = libft.a
LFT_DIR         = libft
LFT             = $(LFT_DIR)/$(FT)
LSDL            = $(LSDL_DIR)/$(SDL)
LTTF            = $(LTTF_DIR)/$(TTF)
NAME            = exu100
###########################color code
BLACK        := $(shell tput -Txterm setaf 0)
RED          := $(shell tput -Txterm setaf 1)
GREEN        := $(shell tput -Txterm setaf 2)
YELLOW       := $(shell tput -Txterm setaf 3)
LIGHTPURPLE  := $(shell tput -Txterm setaf 4)
PURPLE       := $(shell tput -Txterm setaf 5)
BLUE         := $(shell tput -Txterm setaf 6)
WHITE        := $(shell tput -Txterm setaf 7)
RESET         = \033[0m
############################Libraries
INCS_DIR := inc
INCS_DIR += $(LFT_DIR)
############################Compilation
SRCS_DIR = srcs
OBJS_DIR = objs
############################FILE
INCS := inc/wolf_3d.h
INCS += libft/libft.h
###########
SRC := main.c
SRC += stock_map.c
SRC += texture.c
SRC += events.c
SRC += wolf_miniMap.c
SRC += init_wolf.c
SRC += game_engine.c
SRC += outils.c
SRC += sdl_init.c
SRC += mini_map.c
######################
LSDL_DIR         = $(HOME)/.brew/Cellar/sdl2/2.0.12_1/lib
LTTF_DIR         = $(HOME)/.brew/Cellar/sdl2_ttf/2.0.15/lib
INCS_DIR        += $(HOME)/.brew/Cellar/sdl2/2.0.12_1/include/SDL2
INCS_DIR        += $(HOME)/.brew/Cellar/sdl2_ttf/2.0.15/include/SDL2
########################################3Linked libraries at compile time.
LIBS            := -L$(LSDL_DIR) -lSDL2
LIBS            += -L$(LTTF_DIR) -lSDL2_ttf
LIBS            += -L$(LFT_DIR) -lft
LIBS            += -lm
LTTF             = $(LTTF_DIR)/$(TTF)
D_SRCS           = $(addsuffix /, $(SRCS_DIR))
D_OBJS           = $(addsuffix /, $(OBJS_DIR))
C_OBJS           = $(addprefix $(D_OBJS), $(OBJS))
C_INCS           = $(foreach include, $(INCS_DIR), -I$(include))
# How files should be compiled.
CC              = gcc
OBJS            = $(SRCS:.c=.o)

# Compilation flags.

CFLAGS          = $(C_INCS) -Wall -Wextra -Werror
#----------------->>>>>>>>>>>>>>>>START<<<<<<<<<<<<<-------------------#
$(D_OBJS)%.o: $(D_SRCS)%.c $(INCS)
    @echo "$(YELLOW)------->Compiling :$(RESET)" $<
    @$(CC) $(CFLAGS) -c $< -o $@


all: $(C_OBJS) $(NAME)


$(NAME): $(LSDL) $(LTTF) $(LFT) $(C_OBJS)
    @echo "$(YELLOW)\n------->Building $(RESET)$(NAME) $(YELLOW)...\n$(RESET)"
    @$(CC) $(CFLAGS) -o $(NAME) $(C_OBJS) $(LIBS)
    @echo "$(GREEN)***   Project $(NAME) successfully compiled   ***\n$(RESET)"

print-%  : ; @echo $* = $($*)

####  make libft

$(LFT):
    @make -sC $(LFT_DIR)

### creating files for object.o

$(OBJS_DIR):
    @mkdir -p $(OBJS_DIR)


and when i check with {make print-C_OBJS} It seems .o file not there

M. YUSUF
  • 11
  • 1

1 Answers1

0

In the makefile

############################Compilation
SRCS_DIR = srcs
OBJS_DIR = objs

But these folders do not exist in your root folder.

Either rename the folders or modify the makefile accordingly.

Erdal Küçük
  • 4,810
  • 1
  • 6
  • 11