thanks for videos on make! Could you go over these topics by any chance: - VPATH - implicit variables - automatic header dependency management - building external library as a prerequisite (for example googletest) and link against them
@mshingote3 жыл бұрын
Cool. Can you also make a video on cross platform build system. Cmake, premake etc?
@nagarajahuliyapuradamata34473 жыл бұрын
+1
@jacobschmidt3 жыл бұрын
honestly one of the most helpful videos I've seen, thank you
@JacobSorber3 жыл бұрын
You're welcome! Glad you liked it.
@bloom9454 ай бұрын
!! at 7:49, be VERY careful when using make clean like that. I accidentally deleted every regular file on my pc because I changed the name of my DIR variable, making it empty when substituting into the expression "rm -rf $(DIR)/*". Typing "make clean" essentially ran "rm -rf /*", deleting most of my filesystem. Not fun! I suggest always prefixing with ./
@reverse_shell3 жыл бұрын
This is a great topic to continue as the startup for projects is critical, please continue this series!
@JacobSorber3 жыл бұрын
Thanks. Are there project setup topics you would specifically want me to address?
@reverse_shell3 жыл бұрын
@@JacobSorber I didn't even see a notification until today! Wow, but having multiple library directories and a main project. How to chain these together appropriately and work with the build system in an optimal manner. Let's safe for purposes of video length, you'd have 2 x small example libraries and 1 x main project folder to compile the executable. How do we handle this for both release and debug builds?
@Slime_Head3 жыл бұрын
This would have been so useful in my first year of university. I looked around for this kind of stuff, but found little information at the time. Awesome video!
@wilfreddv3 жыл бұрын
I jokingly said "eat the frog, make a script that sets up a project for you". I actually finished it :d
@lucasteixeira53463 жыл бұрын
Amazing video. I just tried to reproduce these concepts in my own makefile and had a few problems, so maybe I can share some points that I figured out. From what I understood, the "variables" are, in fact, macros. This means that their values are substituted when called, so trailing white spaces can become a problem. For example, I wrote the following line: SRC = src # Source files directory This became a problem, because $(SRC)/file.cpp would become "src /file.cpp" (mind the space before the slash). Therefore, I had to change to: # Source files directory SRC=src Anyway, this is what I understood, hope it can help someone.
@ewrietz3 жыл бұрын
Awesome video, I’m just getting into make. Makefiles always looked like gibberish until I watched this series
@JacobSorber3 жыл бұрын
Nice. That's what I'm going for. Glad I could help.
@anon_y_mousse2 жыл бұрын
An excellent addition to the first video.
@mbilalsheikh3 жыл бұрын
your videos are awesome jacob you put a lot of effort to be concise and it really shows
@papasmurf91462 жыл бұрын
A good scripting exercise is to write a script that creates the Makefile. Between header dependencies (which is missing from the simple wildcard based Makefiles) and the difference between tabs and spaces, hand crafting/maintaining a Makefile gets old very quickly with a project of any size.
@weremsoft3 жыл бұрын
I’d like to see how you habdle complex structures inside the src folder. Like deep ly nested folders with .h and .c files. Thanks
@nashs.42062 жыл бұрын
Great video! One way to expand on the content of this video would be to implement dependencies on header files.
@neillunavat3 жыл бұрын
You sir are a saviour... I spent 19 hours trying to get my makefile to work with this project setup I have and then I saw you upload this video. Thank god. Also, I would like to know how to make the the Makefile to recompile if any custom header files change... Thanks
@m4xdev3 жыл бұрын
Adding/modifying like the following should do the trick: CFLAGS=-g -Wall -MD # "-MD" means Make Dependencies DEPS=$(patsubst $(SRC)/%.c, $(OBJ)/%.d, $(SRCS)) # "-MD" outputs makefile dependency files with .d extensions so lets generate a target list -include $(DEPS) # Run each dependency makefile but don't report an error if something fails("-")
@hbobenicio2 жыл бұрын
The %.o: %.c matching pattern is good for simple projects, but not really precise in some bigger ones. For example, it doen't recompile some source files which depend on some other header files which do not have its .c counterpart. In big projects it's really a mess and a nightmare to keep track of dependencies manually. That's why most modern C/C++ compilers support autodependency file generation with -MD and -MP flags which could be used in conjunction with -include in Makefiles to ease this process. Last thing to note is that there are some missing .PHONY rules to be more precise too. It's not easy to make good scalable Makefiles for big project by hand though. That's when I go to CMake or meson. Anyway, it was a great video! I really enjoy and learn a lot watching your channel!
@Silverdragon983 жыл бұрын
Nice one Jacob, I've set this up now for myself. One other thing I did that others might find useful, is a make target to run valgrind. This way you can use to test for memory leaks on all versions.
@swarnavasamanta26283 жыл бұрын
Awesome video. Will you in the future make a video explaining directory structures for common open source projects ? Like those include, libs, and other dir that we see in open source projects in GitHub but have no idea how they are designed. Thank you.
@archibald-yc5le3 жыл бұрын
Thanks for the great tips! I'd love to see a video about testing with make. I have my own routine with a bunch of test-* rules but the catch is that some test modules/cases are much bigger than others, which creates total spaghetti in my project environment. Moreover, at some point you realize some project parts deserve their own folders and even Makefiles but it's always too late. A video on how to manage tests would be deeply appreciated!
@nagarajahuliyapuradamata34473 жыл бұрын
1. I often use layered architecture while programming. Therefore, it makes sense for me to keep source files in different sub folders within $(SRC). How would you modify above Makefile to accommodate? 2. I often (CD/CI) incremental build/compile projects on different machines/devices (ex. Apple tablet or Samsung Tablet or Samsung mobiles, depending on which my family members are not using/left out device) using corresponding device specific Linux emulators. A structured $(BIN)/$(PLATFORM) arrangement in Makefile example would benefit hobby developers like me. Thanks!
@SoulSukkur3 жыл бұрын
For most of my applications, I prefer to keep different sources in different 1-deep subdirctories, which requires more complex shenanigans to have all of them searched seamlessly. also, i think with this setup, if you update a header file, this makefile won't know to recompile everything that included it. For that, I learned about the -MMD flag, which creates files containing depenendencies which can be imported into the makefile. both clang and gcc have the MMD flag.
@hagen15553 жыл бұрын
I'd like to see a quick video about library paths in make. I've tried these -I -L options, but it somehow still doesn't work :/
@boxedowl3 жыл бұрын
Anything Make or C related I'm here for.
@10e9993 жыл бұрын
Great video. Here's some topic idea that are interesting IMO: Makefile dependency management and ./configure script
@fusca14tube3 жыл бұрын
Excellent! Please, make a video explaining this DEBUG symbol. I really did not understand why are you using NDEBUG instead of simple DEBUG. Thanks.
@smrtfasizmu61612 жыл бұрын
This channel is golden
@JacobSorber2 жыл бұрын
Thanks.
@nemis1232 жыл бұрын
Thanks, I needed that.
@gavridgeway3 жыл бұрын
Awesome vid!
@nikhilreddydev3 жыл бұрын
What if I need a binary for each source file in src folder?. Like I need a structure like following / ---src/ ---bin/ Makefile. Can someone guide me on this?
@michelles.38353 жыл бұрын
This was really useful. Do you have any tips on source directories with more folders inside them?
@suncrafterspielt94793 жыл бұрын
Hey i am interested in a detailed debug an release build video
@JacobSorber3 жыл бұрын
I'll put it on the list and see what I can do. Thanks.
@diegoporras7769 Жыл бұрын
Do we aways need to have intermediate object files (.o) and then link or can I just compile w/o the -o flag all together?
@integral11913 жыл бұрын
I definitely needed this
@naveencrasta26853 жыл бұрын
New to Make. Simple and clear! How about header files in include/ ?
@gn033986043 жыл бұрын
Good tip! thank you so much for introducing in this vedio
@RAMB0VI Жыл бұрын
Does this notation work on windows platform?
@xhivo972 жыл бұрын
How can I include external libraries in my project with their source files and compile a statically linked binary? Specifically I wanna use libpng, libz and libjpeg.
@khomo122 жыл бұрын
A bit more advanced but very cool!
@EnkoVlog3 жыл бұрын
Thanks for exp. Could you please create similar lesson for CMake?
@JacobSorber3 жыл бұрын
At some point, there will definitely be a cmake video on here. Just not sure when. It's on the list (but it's a good-sized list).
@pajeetsingh3 жыл бұрын
0:06 Omg! Pls tell me that music name. I've heard it and can't find the source. It's giving me headache.
@basedboi88523 жыл бұрын
Will you do a video on higher level (and cross platform) build systems like CMake?
@lifeless97683 жыл бұрын
Thank you so much :D
@warrenbuckley32673 жыл бұрын
Hey Jacob, I'm curious why you don't use Cmake? Just familiarity?
@JacobSorber3 жыл бұрын
I'm familiar with cmake, and have used it from time to time. I'm not in love with it - probably a product of the sort of work I do - but I can see why others like it. Also, in my classes, I prefer to use build systems with less magic, so the students can more easily understand what is actually going on. Still, there will probably be a cmake video in the future.
@cernejr3 жыл бұрын
Nice tutorial, but still quite simplistic. With a real-world project one would not be overwriting debug and release binaries in the same directory, there should be dedicated rls and dedicated dbg dirtrees. Designing build is often tedious/painful, but also extremely important. Cut corners and you will pay the price over time. Not sure if you should make more videos on this subject - one can spend a lot of time on this and it is a dry/tedious subject. Maybe just make a video illustrating how much effort/complexity real-world builds entail. And in that context please also mention cmake, it is pretty much industry standard.
@sukivirus3 жыл бұрын
Hi Jacob good work. I follow your videos to learn more about C programming but lately I found visual studio much more useful than vs code because it points out mistakes in memory allocation/deallocation by providing warning immediately by syntax highlighting. Also I feel as the project grows its easier to add more files and work on it and worry about make file stuff. May be I am a windows user so make file will be much useful in other operating system. Your thoughts are appreciated. Thanks
@JacobSorber3 жыл бұрын
I have talked about how I feel about IDEs in a few other videos. They're fine, but for new programmers, I prefer tools/systems that hide fewer details from the student.
@themiwi2 жыл бұрын
While for the very simple, one-off stuff I use raw make, it really doesn't scale when you go cross-platform or have dependencies. Adding a basic project setup with CMake is a breeze, abstracts a lot of the nitty gritty tedious details and platform differences away and lets you focus on the important stuff. That's not to say that programmers shouldn't understand make and the low-level details of building a binary, but that doesn't mean you should *always* have to deal with it.
@benjaminshinar95093 жыл бұрын
really timely video, I had to update my makefile last week. some questions: how do you account for both windows and unix systems in the same makefile? i found a flag that detects the OS and i use it to replace my rm (to del) and my .out to .exe, but it still feels weird. I have an issue that if i update a h file (cpp, so the templated code), it doesn't rebuild properly until i clean everything. is there a correct way to handle this?
@integral11913 жыл бұрын
would have been great if you would have discussed multiple sub folders inside of src because I'm confused
@Slime_Head3 жыл бұрын
Could you make a video on phony targets in make?
@integral11913 жыл бұрын
also im making a Makefile, but when I go to run make, its saying that there is a duplicate of every single one of my functions
@dhruvildave8873 жыл бұрын
Best best best!!
@praenubilus19803 жыл бұрын
Is it possible to have a tutorial about CMake?
@JacobSorber3 жыл бұрын
We don't know yet. But, probably. 🤔 I'll see what I can do.
@TheVertical923 жыл бұрын
i dont get the 'all: $(BIN)' rules 🤔 First of all, what does it? And when i use this, i always get the error: make: *** No rule to make target 'bin/main', needed by 'all'. Stop.
@RockTo113 жыл бұрын
Do you have thoughts on Unity Builds (not the game engine): en.wikipedia.org/wiki/Unity_build
@marusdod36853 жыл бұрын
this would've been very useful like, months ago. I ended up switching to cmake xD
@Hellohiq103 жыл бұрын
When you are so early there isn’t any comments.
@IrizarryBrandon3 жыл бұрын
When you're so early you're able to put a "like" on each comment :)
@PiyushASupe3 жыл бұрын
Much needed ine
@tomnetoo Жыл бұрын
The best of all is that you never get drunk.
@slayerofyounglings663 жыл бұрын
CMake is your friend. Mostly.
@ladyViviaen3 жыл бұрын
rust programmers be like : cargo new how_it_feels --bin