Contents
Where do I Find my Makefile in my project?
My directory structure is like this project/src project/bin. My Makefile is in the project (root) folder, and all my *.h and *.c are in the src directory. Currently I have only one source file called timeout.c However, the make seems to create the object file in the project root folder where the Makefile is.
Why does OBJ file not work with makefile?
What you’ve tried to do (obj/%.o: %.c) doesn’t work because of makefile built-in rules. There’s already a built-in rule “%.o: %.c” that exist that will built objects where the source is. Make is an amazing tool and I’m sure you can achieve what you want more easily with some makefile magic but for the moment, here’s what I propose.
Where does make create object files in a project?
However, the make seems to create the object file in the project root folder where the Makefile is. Should it not put it in the src directory? You haven’t noticed yet, but the rule makes each object dependent on all sources, and tries to build that way. Not a problem as long as you have only one source.
How to make makefile to recompile only changed files?
Changing the makefile as per suggestions seems to have the same problem:: The specific problem you’re talking about — Make rebuilds program1 (by relinking the objects) even when nothing has changed — is in this rule: The target of this rule is program, and Make assumes that it is a file.
How does makefile copy files to bin folder?
It will also copy all files from a ‘resources’ folder, into the bin folder when the project is compiled, which I find handy most of the time. To provide credit where it is due, the auto-dependencies feature was based largely off Scott McPeak’s page that can be found HERE, with some additional modifications / tweaks for my needs.
How do I make a file to create a directories?
In an attempt to create a file called create_directories, it runs mkdir -p $ (OBJ). For create_executable, it needs to rebuild create_objects. For create_objects, it just verifies that all of the source files are present.