Creating my own makefile [Error 255]
It looks like you are trying to run your executable after you have built it?
It that case the problem is that you don't have your current directory on the PATH; so make can't find $(EXEC)
.
You should probably just do ./$(EXEC)
to run it directly.
And you should move executing the program to a different (PHONY
) target, so that you can do just the build step on its own, and run when $(EXEC)
doesn't need to be built.
(I'm assuming the lack of tabs is just stackoverflow formatting, as otherwise make
would be complaining).
Elgoog
I would like to say that I am an entrepreneur, but I'm probably more likely a dreamer. I'm a systems administrator constantly learning new things. Linux and Programming are my passions and I am always looking to learn more.
Updated on July 09, 2022Comments
-
Elgoog almost 2 years
I have been enjoying the luxury of coding with an IDE that writes my makefile's for me, Iv decided that I have been 'short cutting' for far to long, so I have read a few manuals and watched a few videos on makefiles and have a makefile semi-done, the only trouble that I'm having is I'm not sure how to link libraries.
CPPS := $(shell ls src/*cpp) TEMP := $(subst src/,obj/,$(CPPS)) OBJS := $(subst .cpp,.o,$(TEMP)) HEADERS := $(shell ls inc/*.h) EXEC := bin/testfile all: $(EXEC) $(EXEC) : $(OBJS) $(HEADERS) g++ -I inc/ $(OBJS) -o $(EXEC) -lSDL -lGLU $(EXEC) obj/%.o: src/%.cpp g++ -Wall -I inc/ -c $< -o $@
ps: just incase I am saying the wrong thing when I say 'Library flags' I mean
-lSDL -lGLU
etc...Wherever I put them they dont seem to work.
This is the error I get when I insert the lib flags,
make: *** [bin/testfile] Error 255
The Error 255 is produced by make as a result of its command shell not being able to find a command for a particular rule.
If i dont include them I get standard 'undefined' messages.
Any help with this would be greatly appreciated! Thank you
-
Elgoog about 12 yearsYour bang on the money there! thanks, am I linking the libraries correctly? my prog doesn't seem to be executing, but no error displays. Yet when built using an IDE it works just fine...
-
Douglas Leeder about 12 years@Elgoog I'm afraid you haven't provided enough information; Have you made the changes I suggested? I'd removing executing the program from your Makefile, and running it directly - then it's easier to see what's going on.