How all C/C++ build Systems Work (Except for CMake and Premake)

  Рет қаралды 8,584

Kea Sigma Delta

Kea Sigma Delta

Күн бұрын

This video was inspired by a comment suggesting a video series on build systems. While I could do that (and will), pretty much all C/C++ build tools do the same thing, with the exception of odd-balls like CMake and Premake.
In this video Hans explains how C/C++ build systems work, and why CMake and Premake are different.
Click the following link for a summary:
keasigmadelta.com/blog/how-ev...
Other useful resources:
- Learn how to build software with C++'s de-facto standard build system: cmaketutorial.com/
- Learn OpenGL ES 3 + SDL2: keasigmadelta.com/gles3-sdl2-...
- More made by us: keasigmadelta.com/store/
- Support inquiries: keasigmadelta.com/support/
Connect with us:
- / keasigmadelta
- / keasigmadelta
- t.me/keasigmadelta (Telegram)
- keasigmadelta.com/subscribe/
QUESTION - What would you like us to make next, on this channel? Comment below...
About
At Kea Sigma Delta we enjoy creating awesome stuff using software & electronics, and helping others to do the same.

Пікірлер: 68
@SPimentaTV
@SPimentaTV 25 күн бұрын
that's exactly what I was searching for! Learning C is rather simple, but when I started to search for compilers and build systems, I starting to get lost 🙈 Thank you for the explanation, and eager to watch the following videos 👍
@KeaSigmaDelta
@KeaSigmaDelta 24 күн бұрын
You're welcome. Great to hear it's what you were searching for.
@usopenplayer
@usopenplayer 26 күн бұрын
It's funny that I've compiled so much code over the last decade, but I've never heard anyone break this concept down and state it so simply. Wish I had this video when I was confused and getting started! I AM going build another build system though. Sorry about that.
@KeaSigmaDelta
@KeaSigmaDelta 26 күн бұрын
I wish I had a video like this when I got started. As for your upcoming build system. I both wish you wouldn't, and wish you all the best. Maybe your one will finally be the one "that doesn't suck."
@patflyer
@patflyer 26 күн бұрын
That last sentence was one of the funniest damn things I've heard in weeks.
@KeaSigmaDelta
@KeaSigmaDelta 26 күн бұрын
Hehe. It was a plea straight from the heart...
@Dmytro-Tsymbaliuk
@Dmytro-Tsymbaliuk 22 күн бұрын
I wrote a simple build system in C++ with compile-time configuration In the build system library, there is simply a function that recursively compiles the files in a given directory into 1 executable file, and this is enough for me, the result is a simple configuration file and the compilation starts as quickly as possible Multiprocessor compilation is present
@KeaSigmaDelta
@KeaSigmaDelta 22 күн бұрын
Great that it works for you.
@bersK00
@bersK00 26 күн бұрын
These standards for build systems suck! I better add a new “better” standard to fix all the issues of the previous ones! /s (this is how we ended up here)
@KeaSigmaDelta
@KeaSigmaDelta 26 күн бұрын
Yep. Just like this: xkcd.com/927/
@flightman2870
@flightman2870 24 күн бұрын
Subscribed. Waiting for the video
@josephbrandenburg4373
@josephbrandenburg4373 19 күн бұрын
Really helpful video
@bradocksolo
@bradocksolo 27 күн бұрын
Great video, thanks!
@KeaSigmaDelta
@KeaSigmaDelta 26 күн бұрын
Glad you liked it!
@sanjikaneki6226
@sanjikaneki6226 20 күн бұрын
can u also make a more in depth example vid on how each work includeing cmake?
@KeaSigmaDelta
@KeaSigmaDelta 19 күн бұрын
That's the plan. I already have more in depth videos for cmake: kzbin.info/aero/PLORJX3OiHbbOBnj4l5boc1wayYg4wic0O
@thesun___
@thesun___ 23 күн бұрын
Making incremental builds using a shell script is actually quite easy. I just think that many people don't always want to put in the effort of learning shell scripting, thus the invention of fancy build systems.
@KeaSigmaDelta
@KeaSigmaDelta 23 күн бұрын
Do you have an example script that can do it?
@fiona9891
@fiona9891 25 күн бұрын
i think the better solution could be to have build scripts in the project's main language, with *maybe* an (ideally small and uncomplicated one file) library to help implement incremental compilation where it's necessary that way everyone working on the project will already be proficient at the language they use to compile it, and at worst they'll have to learn how a small library works granted this only works if you keep the library small, as soon as you try to add a ton of unnecessary features to make it easier you completely ruin the whole idea of being easy to learn
@paradox8425
@paradox8425 25 күн бұрын
That's chicken egg problem. You need to compile that file to get your build details, unless you use some kinda weird cpp interpreter. Also that means build scripts can access everything and do everything which might be bad for security
@fiona9891
@fiona9891 25 күн бұрын
@@paradox8425 i mean, you don't really need to have to have a complex build tool to compile a single file and run it, just a compiler plus it's not really any more unsafe than like, a makefile
@paradox8425
@paradox8425 25 күн бұрын
@@fiona9891 It's usually not a single file tho. You use one for tests, one for each dependency, etc I mean you can run any arbitrary code in a cpp file. Literally anything
@KeaSigmaDelta
@KeaSigmaDelta 25 күн бұрын
I think Jonathan Blow might be experimenting with a similar idea with Jai, a new programming language that he's working on.
@fiona9891
@fiona9891 25 күн бұрын
@@paradox8425 yeah, but makefiles (and other common build systems) can execute programs on your computer, which means it can do basically anything a c program can like, theoretically you could make a makefile that writes a c program and compiles it then runs it, so i don't think it's necessarily any more unsafe plus, you can have your main build script build the other files once you execute it, so i think it can potentially still work in that situation (i'm not sure how unwieldy that would be, it's hard to say without seeing it in action, but i'm hoping it shouldn't be too bad and i think using the same language to build your project is a pretty massive benefit) it also means you don't really have to worry about someone having a different version of a build tool because the entire build tool is right there in your project, which you have to agree is pretty great
@cycleoffire2220
@cycleoffire2220 24 күн бұрын
What stoppes me from checking if file changed in the script (for example using git hooks, hashing or timestamps) and then build only that .o, then link .exe file? If so, what's the caveats? Sorry if the question is stupid, only started to learn build systems and shell, and want to understand it's advantages and disadvantages.
@KeaSigmaDelta
@KeaSigmaDelta 24 күн бұрын
Comparing timestamps is basically how it's done. However, checking the timestamp of the source-file is *NOT* enough. You need to check if any of the source file's dependencies have changed too. So, you check the header files that it includes, then check the header files that those header files include, and again and again... You're better off using a build tool that already does the change detection rather than try to recreate it on your own.
@cycleoffire2220
@cycleoffire2220 24 күн бұрын
@@KeaSigmaDelta Oh, so this is basically how makefile works? Plus dependancies and flags of course. Thanks, it really helps to understand makefile workflow better!
@KeaSigmaDelta
@KeaSigmaDelta 24 күн бұрын
@@cycleoffire2220 Yes, although with makefiles you need to add some special code to get the dependency change tracking to work. I cover that in this video: kzbin.info/www/bejne/lXWylaJ3f8tkbc0 (and will do so again in a future cmake vs make video)
@deoabhijit5935
@deoabhijit5935 27 күн бұрын
Nice
@KeaSigmaDelta
@KeaSigmaDelta 26 күн бұрын
Thanks
@paradox8425
@paradox8425 25 күн бұрын
But what if I need a specific feature that none of the build systems support?
@KeaSigmaDelta
@KeaSigmaDelta 25 күн бұрын
Some build systems are very extensible, so I doubt you'd ever get to that point. If you do, my recommendation would be to stop, and take some time to think about what you're doing and why. Are you making things more complicated than needed?
@paradox8425
@paradox8425 25 күн бұрын
@@KeaSigmaDelta Well my current need is include modules(not c++ modules), libraries, etc into the build system, if they are needed by project. Only this might not make all the sense in the world, but I also want to know if a module is enabled or not so I can take different code paths (for example: "#if MODULE_XYZ_PRESENT") And my current approach is kinda extending CMake not a standalone build system. So I generate a CMake script at the end with all the required includes and defines
@KeaSigmaDelta
@KeaSigmaDelta 24 күн бұрын
​I personally go for simplicity. So, I err strongly on the convention over configuration side. I want building my code to be easy too, not just the end program. This means minimal options/configurations. When adding more options I ask the question: "is the benefit of this feature/option worth the added complexity and future maintenance?"
@paradox8425
@paradox8425 24 күн бұрын
@@KeaSigmaDelta Well, I think it's worth. It also means I don't need to write CMake that often which is nice.
@KeaSigmaDelta
@KeaSigmaDelta 24 күн бұрын
@@paradox8425 Sounds good.
@playbahn
@playbahn 24 күн бұрын
"Please don't add another build system" XDDD
@hamzakhiar3636
@hamzakhiar3636 24 күн бұрын
I don't get why clang for Mac and not for all three, isn't making new programming languages uses cpp with llvm??
@KeaSigmaDelta
@KeaSigmaDelta 23 күн бұрын
You certainly could try to use your preferred compiler on all platforms if you want. Do bear in mind that each platform has its preferred and best supported compiler toolchain, and using one of the others may come with issues. For example, I do use GCC on Windows, but have run into issues (e.g., certain APIs that aren't supported yet).
@Kitsune_Dev
@Kitsune_Dev 24 күн бұрын
I’m really confused with what tools to use and how, I’m using Lua and Luau for automation but I can’t seem to figure out how to use FFI I also want to learn low level language like C/C++, Rust and Zig but it is really overwhelming
@KeaSigmaDelta
@KeaSigmaDelta 24 күн бұрын
Lua FFI is only of interest if you already have C code to call. You've listed a lot of different things. I suggest you pick one, and focus on that for now. My CMake Tutorial (cmaketutorial.com/) can help with compiling C/C++ code, but I don't have a beginners C/C++ tutorial (yet). Most people seem to recommend www.learncpp.com/. The Rust language has some good tutorials out there. I've heard about Zig, but have zero experience with it.
@chigoziethankgod9579
@chigoziethankgod9579 21 күн бұрын
To aid you a bit, you shouldn't be aiming to learn languages, but programming concepts and c++ will help you with that, with c++ you could grasp most of the concepts in C & most other high level languages (Java, Python) and the rest, the underlying concepts are basically all the same, Difference is in C, you mostly have to work with algorithms, and higher level languages (APIs and framework's)
@chigoziethankgod9579
@chigoziethankgod9579 21 күн бұрын
Don't freak out or see it as something so tedious or cumbersome, and don't also waste time trying to understand all the concepts, if you don't understand something move past it, as time goes on you'll get it for sure, might be years but you'll understand it. I understand some concepts 3 years later and still understanding concepts till date, most top programmers don't understand all the concepts..
@Kitsune_Dev
@Kitsune_Dev 13 күн бұрын
@@chigoziethankgod9579 thank you for the advice, I have been programming with lua for almost 8 years, I’m struggling to find a job that’s why i need to learn other languages
@wuksi
@wuksi 23 күн бұрын
Please compare meson to cmake.
@KeaSigmaDelta
@KeaSigmaDelta 22 күн бұрын
Meson is on the list. I've heard good things about it...
@danielnoriega6655
@danielnoriega6655 25 күн бұрын
I really like CMake autoconf/make was a pain in the but
@KeaSigmaDelta
@KeaSigmaDelta 24 күн бұрын
It's refreshing to hear someone say they like CMake because some love to hate it. I found autoconf to be a nightmare, but got pretty good at using make.
@DeathSugar
@DeathSugar 20 күн бұрын
The killer feature of build systems - dependency management, not incremental builds. Which files to build ,where to find internal/external dependencies, what order those dependencies should compile and how to pass those to linker and so on. Incremental builds could work just by using things like ccache and it's not necessary part of the build systems by itself. Also there's at least 4 kinds of compile times optimizations there are includnig caching, parallel building (multiple machine compile different parts of the project), multicore building and smashing files together into big ones. And of course they can be done all at the same time to a certain degree, since each of it introduce it's own quirks to the build system.
@KeaSigmaDelta
@KeaSigmaDelta 19 күн бұрын
Very few C/C++ build systems have dependency management... Of course build systems have more features than mentioned in the video, but if you throw all of them at a beginner then they'll get overwhelmed.
@DeathSugar
@DeathSugar 19 күн бұрын
@@KeaSigmaDelta you literally place what files to build in the script. whats that if not a dependency management.
@KeaSigmaDelta
@KeaSigmaDelta 17 күн бұрын
@@DeathSugar That's simply telling it what files to compile & link to.
@DeathSugar
@DeathSugar 17 күн бұрын
@@KeaSigmaDelta okay, whats dependency management is then? except for resolving system search paths to shove into compiler/linker options and installing them from some kind of registry, what else it is?
@KeaSigmaDelta
@KeaSigmaDelta 17 күн бұрын
​@@DeathSugar Let's use the Rust language's dependency manager as an example. It's called "cargo." You tell it what external packages/libraries you need, and it'll fetch them from the internet and install them for you. It'll also install dependencies to those dependencies.
@MichaFita
@MichaFita 21 күн бұрын
And Rust has one. Actually two, but that's Google's fault.
@PeakKissShot
@PeakKissShot 21 күн бұрын
Meson the best
@KeaSigmaDelta
@KeaSigmaDelta 20 күн бұрын
We'll see...
@StarEclipse506
@StarEclipse506 23 күн бұрын
One minute in and I'm infuriated no docs explained the gcc -o prog.exe *.o thing as well as you did
@KeaSigmaDelta
@KeaSigmaDelta 22 күн бұрын
Thanks. The docs are usually written by people who "know too much," and therefore think that everything is obvious.
@sameerakhatoon9508
@sameerakhatoon9508 27 күн бұрын
subscribed, thanks
@KeaSigmaDelta
@KeaSigmaDelta 26 күн бұрын
Great! Thanks for the sub.
CMake vs Make - a real life comparison (with actual code)
12:16
Kea Sigma Delta
Рет қаралды 185
What Is Systems Engineering? | Systems Engineering, Part 1
15:36
Do you have a friend like this? 🤣#shorts
00:12
dednahype
Рет қаралды 55 МЛН
Ну Лилит))) прода в онк: завидные котики
00:51
СҰЛТАН СҮЛЕЙМАНДАР | bayGUYS
24:46
bayGUYS
Рет қаралды 821 М.
UFC 302 : Махачев VS Порье
02:54
Setanta Sports UFC
Рет қаралды 1,3 МЛН
15 Years Writing C++ - Advice for new programmers
4:04
SyncMain
Рет қаралды 1,1 МЛН
CMake vs Make - A developer's perspective
8:16
Kea Sigma Delta
Рет қаралды 3,4 М.
Teaching myself C so I can build a particle simulation
11:52
Gradience
Рет қаралды 175 М.
1. C++ Cross Platform Build System - Celeste Clone
15:40
Why I Like Programming in C.
3:16
Francisco Jinto Fox
Рет қаралды 18 М.
CMake, How it Works (At Three Different Levels)
4:36
Kea Sigma Delta
Рет қаралды 7 М.
how Google writes gorgeous C++
7:40
Low Level Learning
Рет қаралды 770 М.
Become a shell wizard in ~12 mins
12:25
CODE IS EVERYTHING
Рет қаралды 212 М.
Why i think C++ is better than rust
32:48
ThePrimeTime
Рет қаралды 268 М.
The Importance of Error Handling in C
8:18
Nir Lichtman
Рет қаралды 28 М.
Дени против умной колонки😁
0:40
Deni & Mani
Рет қаралды 10 МЛН
Выложил СВОЙ АЙФОН НА АВИТО #shorts
0:42
Дмитрий Левандовский
Рет қаралды 1,8 МЛН