DarkT DarkT - 2 months ago 5
C++ Question

How to run program after compiling with Makefile

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 *~ *#

Answer

./assign4a.

Your makefile will build the program and put a executable assign4a to the working folder.

And, your makefile is wrong.

It should be g++ $(CFLAGS) assign4a.cpp -o assign4a.o and g++ $(CFLAGS) list.cpp -o list.o.