I have simple files:
hello.h , hello.cpp
I have created a makefile in order to generate a static library (libhello.a)
but I’m getting error message , what am I doing wrong?
My code is:
CC = g++
CFLAGS = -Wall -g
utilObjs = hello.o
libhello.a: $(utilObjs)
ar rc $@ $(utilObjs)
ranlib $@
hello: hello.o libhello.a
$(CC) $(CFLAGS) hello.o -L ./ -lutil -o $@
hello.o: hello.cpp hello.h
$(CC) $(CFLAGS) -c $>
clean:
rm -rf *.o libhello.a hello
all: hello
.PHONY: all clean
The error message :
g++: fatal error: no input files
compilation terminated
I don’t think
$>means anything special, change it to$<, which expands to the first prerequisite of the rule. (hello.cpp in this case)