2

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.

7
  • You solve this error by making sure there is such file or directory.. Commented Jul 30, 2020 at 13:00
  • Or by changing the reference to where it actually is. This may not be a makefile error but an include error. Commented Jul 30, 2020 at 13:01
  • If your sure all of the syntax is correct, but still seeing this error, then take a look at this conversation about Cmake is not able to find Python-libraries Commented Jul 30, 2020 at 13:09
  • That $(shell ...) construct is not doing anything useful. If you were expecting it to add /usr/local/lib/python3.5/dist-packages/numpy/core/include to a Make variable called PYTHON_INCLUDE_DIRS, then that's your problem. Use += instead. Commented Jul 30, 2020 at 13:10
  • Setting a shell variable has no effect if you don't use it. You need a -I in your build including that directory Commented Jul 30, 2020 at 13:11

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.