How do I resolve this make fatal error: numpy/arrayobject.h: No such file or directory?

Viewed 519

I have the following snippet in my makefile (the first line was added by me after finding it as a candidate solution online - unfortunately, it doesn't work):

$(shell set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} /usr/local/lib/python3.5/dist-packages/numpy/core/include))

all: obj $(EXEC) link
$(EXEC): $(OBJS)
    $(CC) $(COMMON) -I./src/factor $(CFLAGS) $^ -o $@ $(LDFLAGS)
    $(CC) -shared $(COMMON) -I./src/factor $(CFLAGS) $^ -o $(SHAREDLIB) $(LDFLAGS)
$(OBJDIR)%.o: %.c $(DEPS)
    $(CC) $(COMMON) -I./src/factor $(CFLAGS) -c $< -o $@

I verified that numpy/arrayobject.h is in /usr/local/lib/python3.5/dist-packages/numpy/core/include on my system. After executing make I get:

gcc -I ./include -I/usr/include/python3.5 -DGPU -I/usr/local/cuda-10.0/include/ -DCUDNN  -I./src/factor -Wall -Wfatal-errors -fPIC -Ofast -DGPU -DCUDNN -c ./src/ComputationPy.c -o obj/ComputationPy.o
./src/ComputationPy.c:12:31: fatal error: numpy/arrayobject.h: No such file or directory
compilation terminated.
Makefile:51: recipe for target 'obj/ComputationPy.o' failed
make: *** [obj/ComputationPy.o] Error 1

Line 51 corresponds to the last line of the snippet.

1 Answers

Without seeing the complete Makefile it's hard to be sure what's wrong, but this line looks like it can't possibly be correct:

$(shell set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} /usr/local/lib/python3.5/dist-packages/numpy/core/include))

In GNU make, $(shell ...) runs sh -c "..." [technically, $(SHELL) -c "...") and evaluates to whatever that command prints on its stdout. set(...) is not valid sh syntax, and also, the stuff inside $(shell ...) cannot change Make variables. I would expect this line to print an error message as part of the make log, something like

sh: 1: Syntax error: word unexpected (expecting ")")

and otherwise have no effect.

Assuming the goal here is to append /usr/local/lib/python3.5/dist-packages/numpy/core/include to the value of the Make variable PYTHON_INCLUDE_DIRS, the way to do that is with +=:

PYTHON_INCLUDE_DIRS += /usr/local/lib/python3.5/dist-packages/numpy/core/include

The rules you quoted don't directly make use of this variable, but I suspect there may be a reference to it hiding inside $(COMMON).

Related