I have compiled a makefile project under linux, just yesterday. Now the project won’t compile and I can’t remember making any change whatsoever to the makefile itself. It throws a make: *** No rule to make target 'obj/TranquilMain.o', needed by 'tranquil;. Stop. error at make. The only real change I’ve made, is when I copied the code and makefile over from another project, I changed the name of certain files (and dependencies includes) and then altered the _DEPS in the makefile. All files in necessary locations.
It should be noted that it compiles fine, if I remove all other files than TranquilMain.o from the _OBJ list. enter code hereI wish I could provide more than just code, and this knowledge, but I haven’t a clue what the problem is.
Appropriate Makefile: “makefile”
#!/usr/bin/make
CC = gcc
CP = g++
SRC_DIR = #.
OBJ_DIR = obj
INC_DIR = ../include
LIB_DIR = ../lib
LIBS = -lm -lSDL -lSDLmain -lSDL_image -lSDL_mixer -lSDL_ttf -lSDL_net -lGL -lGLU -lGLEW
CFLAGS = -I$(INC_DIR) -L$(LIB_DIR) -std=gnu++0x
_DEPS = DefaultConfig.h BaseApplication.h BasePlugin.h SDLImage.h SDLFont.h SDLWindow.h SDLInput.h SDLRenderer.h SDLApplication.h Math2D.h SDLTimer.h
DEPS = $(patsubst %,$(INC_DIR)/%,$(_DEPS))
_OBJ = TranquilMain.o BaseApplication.o BasePlugin.o SDLImage.o SDLFont.o SDLWindow.o SDLInput.o SDLRenderer.o SDLApplication.o Math2D.o SDLTimer.o
OBJ = $(patsubst %,$(OBJ_DIR)/%,$(_OBJ))
$(OBJ_DIR)/%.o: %.cpp $(DEPS)
$(CP) -c -o $@ $< $(CFLAGS)
tranquil: $(OBJ)
$(CP) -o ../bin/$@ $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(OBJ_DIR)/*.o *~ core $(INC_DIR)/*~
Clearly useless TranquilMain.cpp (just the first file in the dependencies)
#include <iostream>
#include <fstream>
#include <string>
int main( int argc, char* args[] )
{
bool running = true;
while( running == true )
{
}
return 0;
}
Also, make sure you haven’t inadvertantly turned tabs into whitespace.
A rule MUST begin with a “tab”: