Robert
Robert

Reputation: 2249

makefile error: make: *** No rule to make target `omp.h' ; with OpenMP

all, I was compiling a C program with OpenMP. It's my first time to use makefile. When excuting "make", the gcc reports the error make: * No rule to make target omp.h', needed bysmooth.o'. Stop. However the omp.h is in the /usr/lib/gcc/i686-linux-gnu/4.6/include/omp.h , I am wondering how to fix it. Could anyone help me? Thank you.

CC=gcc
CFLAGS = -fopenmp

all: smooth

smooth: smooth.o ompsooth.o
    $(CC) $(CFLAGS) -o smooth smooth.o ompsmooth.o

ompsmooth.o: ompsmooth.c assert.h stdio.h stdlib.h omp.h ompsmooth.h
    gcc $(CFLAGS) ompsmooth.c

smooth.o: smooth.c ompsmooth.h omp.h stdio.h stdlib.h string.h sys/types.h sys/stat.h     fcntl.h
    gcc $(CFLAGS) smooth.c

clean:

    rm *.o
    rm smooth

Upvotes: 1

Views: 2912

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272607

Unless you're expecting your standard header files to change, the simplest solution is just to remove them from the prerequisite list(s).

If you don't want to do the above, then you'll either need to specify the complete path to omp.h, or use the VPATH mechanism.

Upvotes: 5

Related Questions