C project with Makefile - header file not found

Hello,

I'm running into a peculiar issue with my .c files in CLion not being able to find the .h file that is located in a subfolder of my project.

| Project folder
|-> /src
|    .c files
|-> /inc
|    .h files
| Makefile

CLion on Linux tells me that my header file can't be found (and therefore half my functions are greyed out and innaccessible) unless I give the full path to that header file in the include. On OSX, it works perfectly as is, just the header file name, and corresponding directory included during compilation with the Makefile.

Is there something I should be careful about in the Makefile ? I've seen issues when using implicit wildcards but I actually list all my files:

INC_DIR := inc
BIN_DIR := bin

SRC_FILES := main\
# ...(my .c files)
OBJ_FILES := $(addprefix $(BIN_DIR)/, $(addsuffix .o, $(SRC_FILES)))

all: $(NAME)

$(NAME): $(OBJ_FILES)
@$(CC) -o $(NAME) $(OBJ_FILES)

$(BIN_DIR)/%.o: $(SRC_DIR)/%.c Makefile | $(BIN_DIR)
@$(CC) -MD -c $(CFLAGS) -I $(INC_DIR) $< -o $@

$(BIN_DIR):
@mkdir $(BIN_DIR)

Any help on this would be greatly appreciated, thanks in advance !

1 comment
Comment actions Permalink

Hello!

Please create the "clean" target in your Makefile and after that in CLion do `Tools | Makefile | Clean and Reload Makefile Project`. Does it help?

0

Please sign in to leave a comment.