I'm trying to create a makefile, but I have some confusion.
Here is my makefile…
CXX = g++
DEBUG = -g
TARGET = ??????
CFLAGS = -c -Wall $(DEBUG)
$(CXX) $(CFLAGS) main.cpp
So, say I just wanted to compile a simple main.cpp to print hello world, no header files. What would my TARGET be? I tried 'file', saved it, exited, then typed 'make' into the command line and it said no target specified and no makefile found.
Are there any issues with the rest of my makefile? Other than the tabbing. I couldn't get the spacing to work right on here.
It's been a while since I last wrote a makefile, so I might have gotten something in the following mixed up.
Your $(TARGET): main.o rule would be used to link main.o (and whatever objects you have in the future) into a single executable. Similarly, you need a main.o: main.cpp rule (or a general rule for converting .cpp files into .o files). What you currently have is a rule that Make thinks is supposed to convert main.o into your target... but that's not what happens.
Also, clean should delete all non-configuration files created by Make, not just main.o.
I hope that answers your question (or at least gives you an idea of what to do).