Reputation: 179
I have a assign4a.cpp
, list.h
, and list.cpp
file. I compiled them with my make file but don't know what command I would use to run the program.
What I tried to run have tried
a.out
and ./a.out
both of them give me "Command not found"
Makefile
CFLAGS = -c -Wall -g
LFLAGS = -g -o assign4a
assign4a: assign4a.o list.o
g++ assign4a.o list.o $(LFLAGS)
assign4a.o: assign4a.cpp list.h
g++ $(CFLAGS) assign4a.cpp
list.o: list.cpp list.h
g++ $(CFLAGS) list.cpp
clean:
rm -f assign4a *.o *~ *#
Upvotes: 1
Views: 23988
Reputation: 4110
You need to call
./assign4a
Makefile defines targets and dependencies between them. Here:
assign4a: assign4a.o list.o
g++ assign4a.o list.o $(LFLAGS)
assign4a
is a target, that depends on files assign4a.o
, list.o
, and to build target is needed to run g++ assign4a.o list.o $(LFLAGS)
.
Upvotes: 1
Reputation: 2012
./assign4a
.
Your makefile will build the program and put a executable assign4a
to the working folder.
It should be g++ $(CFLAGS) assign4a.cpp -o assign4a.o
and g++ $(CFLAGS) list.cpp -o list.o
.
Upvotes: 4