It's also worth mentioning that the power of make comes from that it tracks file changes, where if you run make all and then modify only one source file, when you run make all the second time, only that single file gets recompiled and not all files, and if nothing changed it wouldn't recompile again
Thank you for creating this tutorial! Because you explained what the manual way looks like and its pitfalls, it helped me appreciate Makefiles. You are a great teacher!
But make does more than just running tasks. A Makefile also builds a dependency tree so to speak and if you say make xy.o it looks up what is needed for xy.o and first builds that, the proceeds building xy.o. Make can be used for simple task running as well, but it has its quirks. There’s better task runners based on bash out there
thats because makefile has nothing to do with C. its just a software thar allows you to use logic while executing CLI commands. of course, you can use it to compile C projects too
The problem is that the C ecosystem is so scattered and all of those things are separate. When C started, it wasn’t even combined with the preprocesser. This came as an afterthought. Make files as a simple build system that keeps track of dependencies between files and freshness of build artifacts came as an afterthought as well. Documentation with doc comments and doxygen came as an afterthought. Testing is something that was bolted on as an afterthought. But this is also C‘s biggest strength. It’s very flexible.
10:38 Why did you have to do “make clean”? A key point with make is that it only rebuilds the parts that have changed, yet you are forcing it to rebuild everything.
One reason is to rebuild the entire project from scratch, in case something got corrupted along the way or just to be safe when building the final executables. Or maybe just to free some space of build artifacts, once everything is finished.
Doesn't it disturb you having a prompt that takes up more that 2/3 of the screen width? I have shortened my prompt and added line breaks into it so that the information (like host and directory) is on one line and the actual prompt is alone on another line.
What is the point to do -c first and then compile from object files? It will compile if you just put *.c files right? What is the point of this *.o file, it just seems like extra step for no reason.
It is an extra step. The reason is because if you're working on a large project with thousands of files, recompiling every single file will take hours. By splitting the build into separate compiling and linking stages, you can skip the compiling stage for files that don't need to be recompiled.
i dont realy understand how you manage to displaye the content of the function(hello world) minewhile this function is not part of the defferen functioncreated using flags and from what i see they are not diretly connected
Including hello.c in main.c would create one huge .c file when compiling. That prevents you from splitting builds into separate compile and link stages, which greatly slows down builds when you're working on projects with thousands of files. The strength of makefiles is more than just running the gcc or compiler commands for you; makefiles also determine which files need to be compiled and which ones can be skipped.
Ninja is an alternative to makefiles. Make originated at a time when it was expected you would write makefiles by hand. So Make (particularly GNU Make) includes a lot of features for expressing complex rules and expressions and things, to minimize the size of the makefiles you have to write. But nowadays, many if not most makefiles are generated by front-end processors like CMake or Meson or even GNU Autotools. So a lot of the advanced stuff in Make is not really necessary and just duplicates the functionality of those front-end processors. So we have Ninja, which is like a stripped-down reimagining of Make, which assumes that you will use such a front-end processor, rather than writing your Ninja files by hand.
It's also worth mentioning that the power of make comes from that it tracks file changes, where if you run make all and then modify only one source file, when you run make all the second time, only that single file gets recompiled and not all files, and if nothing changed it wouldn't recompile again
Neuralnine casually creating a c files in a python director
Br
Yo
Ar
So goo
Top
Thank you for creating this tutorial! Because you explained what the manual way looks like and its pitfalls, it helped me appreciate Makefiles. You are a great teacher!
this whole time I was writing my own batch file for this, never knew this existed 💀
But make does more than just running tasks. A Makefile also builds a dependency tree so to speak and if you say make xy.o it looks up what is needed for xy.o and first builds that, the proceeds building xy.o.
Make can be used for simple task running as well, but it has its quirks. There’s better task runners based on bash out there
thank you so much man, excellent explanation!
got the clear understanding , GOTCHA
thanks by the way
Well done , CHAP
thank you! I have 3 books on C but no one has told me how to make a Makefile
thats because makefile has nothing to do with C. its just a software thar allows you to use logic while executing CLI commands. of course, you can use it to compile C projects too
The problem is that the C ecosystem is so scattered and all of those things are separate.
When C started, it wasn’t even combined with the preprocesser. This came as an afterthought.
Make files as a simple build system that keeps track of dependencies between files and freshness of build artifacts came as an afterthought as well.
Documentation with doc comments and doxygen came as an afterthought.
Testing is something that was bolted on as an afterthought.
But this is also C‘s biggest strength. It’s very flexible.
I learn something and have hit the like button, thank you very much.😎
Thank you. I used to do huge commands in the terminal but it's high time I use make.
I was looking for this! Thanks.
I finally managed to link libraries because of this tutorial. I can now commit to learning c.
We can also write a build shell script to compile small projects.
Thanks man, very helpful! Subscribed!
Very well explained. Thanks for sharing.
10:38 Why did you have to do “make clean”? A key point with make is that it only rebuilds the parts that have changed, yet you are forcing it to rebuild everything.
One reason is to rebuild the entire project from scratch, in case something got corrupted along the way or just to be safe when building the final executables. Or maybe just to free some space of build artifacts, once everything is finished.
@@tiagobecerrapaolini3812 But it’s not something you would want to do every time.
@@lawrencedoliveiro9104no the point is to simplify the process and write less commands
@@CorneliusCorndogJr The point of “make” is to follow the dependency chain and only rebuild what needs to be rebuilt.
@@lawrencedoliveiro9104 what the first reply says
it's been 3 days and 5 tutorials and finally someone said the makefile should not have a capital f!!! great video you are a great teacher
Doesn't it disturb you having a prompt that takes up more that 2/3 of the screen width? I have shortened my prompt and added line breaks into it so that the information (like host and directory) is on one line and the actual prompt is alone on another line.
Long prompts are not bad if you're using a 2 line prompt, which for bash can easily be fixed with oh my bash
Downside / Consequence of using WSL?
Awesome work! It made clear it all in one video!
Putting a function implementation into a header file is a good idea?
What happens when you include that header file in more than one c file?
the intro is staring at my soul
Excellent video!🙏
What is the point to do -c first and then compile from object files? It will compile if you just put *.c files right? What is the point of this *.o file, it just seems like extra step for no reason.
It is an extra step. The reason is because if you're working on a large project with thousands of files, recompiling every single file will take hours. By splitting the build into separate compiling and linking stages, you can skip the compiling stage for files that don't need to be recompiled.
Thanks! That helped a lot :).
Thank u for uploading this
Thanks, simple and helpful.
Excellent tutorial!
i dont realy understand how you manage to displaye the content of the function(hello world) minewhile this function is not part of the defferen functioncreated using flags and from what i see they are not diretly connected
Thanks man. Clear enough
Very Informative!
Great thank you very much.
Great help!!
Awesome Job!
And you haven't scratch the surface...
Hey, we couldve just included the hello.c file in the main.c code and run gcc main.c. Why are we using makefiles then ?
Including hello.c in main.c would create one huge .c file when compiling. That prevents you from splitting builds into separate compile and link stages, which greatly slows down builds when you're working on projects with thousands of files. The strength of makefiles is more than just running the gcc or compiler commands for you; makefiles also determine which files need to be compiled and which ones can be skipped.
Superb!
thank you so much
does it work on windows too or any equivalent?
I hate makefiles, cmake is much better at generating them (or even using Ninja).
Ninja is an alternative to makefiles.
Make originated at a time when it was expected you would write makefiles by hand. So Make (particularly GNU Make) includes a lot of features for expressing complex rules and expressions and things, to minimize the size of the makefiles you have to write. But nowadays, many if not most makefiles are generated by front-end processors like CMake or Meson or even GNU Autotools. So a lot of the advanced stuff in Make is not really necessary and just duplicates the functionality of those front-end processors.
So we have Ninja, which is like a stripped-down reimagining of Make, which assumes that you will use such a front-end processor, rather than writing your Ninja files by hand.
Thanks
Great!
Thx
guys why it says nv is not found for me?
use touch
❤
Good
RAK GHAYA
What ide are you using? With the nv command
maybe alias dude
Neovim?
Its neovim
@@zjardynliera-hood5609 thanks. sounds like a pokemon or something
Neovim
Jesus christ, change your PS1. That's way too long bro.
Thx_.
👍
you could get zsh shell and use a prompt with break line
That can be easily achieved using a batch file too.
They have more power than that for incremental builds. Makefiles are s**t, but at least they're simple
I need to talk you something important can I,,
Have a think for something if you don't mind
No it fucking don’t.
I wrote 1 make file and almost kms several times.
Tbh to me it seems you got no clue what ya doin
Thanks