Solved Makefile not including preprocessor?

I'm running FreeBSD 14.1 and clang version 18.1.5. I installed the json-c version 0.17 library via pkg and it exists in /usr/local/lib and the headers are in /usr/local/include/json-c.

This is my code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <json-c/json.h>

int main(void) {

    // ---snip---
           
    return EXIT_SUCCESS;
}

Makefile:
Code:
CC                     = cc
CFLAGS            = -Wall -g
CPPFLAGS        = -I/usr/local/include/
LIBFLAGS         = 
OBJFILES         = main.o
TARGET            = fun

all: $(TARGET)

$(TARGET): $(OBJFILES)
    $(CC) $(CFLAGS) $(CPPFLAGS) -o $(OBJFILES)
    
.PHONY: clean
clean:
    rm -f $(OBJFILES) $(TARGET)

When I run make I get: main.c:3:10: fatal error: 'json-c/json.h' file not found
However, cc main.c -o fun -I/usr/local/include/ compiles and produces an executable.

Is there something wrong in my Makefile?
 
You need to write the line that builds the *.o from the *.c. You don't have that and you fall back to an implicit rule which doesn't have /usr/local.
 
Back
Top