<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>beginner coding Archives - NeuralLantern.com</title>
	<atom:link href="https://www.NeuralLantern.com/tag/beginner-coding/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.NeuralLantern.com/tag/beginner-coding/</link>
	<description></description>
	<lastBuildDate>Mon, 23 Jun 2025 02:42:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>

<image>
	<url>https://www.NeuralLantern.com/wp-content/uploads/2025/04/cropped-2025-04-04-Lantern-03-32x32.png</url>
	<title>beginner coding Archives - NeuralLantern.com</title>
	<link>https://www.NeuralLantern.com/tag/beginner-coding/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Caveman Debugging: Simple Trick to Debug C++ Code Like a Pro!</title>
		<link>https://www.NeuralLantern.com/caveman-debugging-simple-trick-to-debug-c-code-like-a-pro/</link>
					<comments>https://www.NeuralLantern.com/caveman-debugging-simple-trick-to-debug-c-code-like-a-pro/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Wed, 11 Jun 2025 19:56:00 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[assembly debugging]]></category>
		<category><![CDATA[beginner coding]]></category>
		<category><![CDATA[c++ debugging]]></category>
		<category><![CDATA[c++ tutorial]]></category>
		<category><![CDATA[caveman debugging]]></category>
		<category><![CDATA[code troubleshooting]]></category>
		<category><![CDATA[coding hacks]]></category>
		<category><![CDATA[coding tips]]></category>
		<category><![CDATA[debug c++]]></category>
		<category><![CDATA[debug code fast]]></category>
		<category><![CDATA[fix code bugs]]></category>
		<category><![CDATA[print statement debugging]]></category>
		<category><![CDATA[programming for beginners]]></category>
		<category><![CDATA[programming tutorial]]></category>
		<category><![CDATA[software development]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=151</guid>

					<description><![CDATA[<p>Master caveman debugging! Easy C++ trick to fix code fast with print statements. Clear tips for beginners &#038; pros. Watch now to squash bugs!</p>
<p>The post <a href="https://www.NeuralLantern.com/caveman-debugging-simple-trick-to-debug-c-code-like-a-pro/">Caveman Debugging: Simple Trick to Debug C++ Code Like a Pro!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Caveman Debugging: Simple Trick to Debug C++ Code Like a Pro!" width="1380" height="776" src="https://www.youtube.com/embed/hsGaRukvpF8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Hey coders! Ever hit a wall with a program that just won’t work? In this video, I’m spilling the beans on caveman debugging—a super simple, no-fuss way to hunt down bugs in your C++ code (or any language, from assembly to Python)! No need to wrestle with complex debuggers; this method is all about using print statements to trace what your code is doing, step by step.</p>



<p class="wp-block-paragraph">I’ll show you a real C++ program where things go wrong (think integer overflows and mystery crashes) and walk you through how to sprinkle in cout statements to spot the problem fast. You’ll learn how to label decision points like loops and if-statements, break down complex expressions with temporary variables, and format your debug output so it’s easy to read. Plus, I share a neat trick called short circuiting to toggle your debug prints on or off without deleting them—saving you tons of time!</p>



<p class="wp-block-paragraph">Whether you’re a beginner just starting out or a pro debugging a massive codebase, caveman debugging is a lifesaver. It’s quick, it’s intuitive, and it fits my “let’s figure this out” vibe perfectly. Stick around to see how I catch a sneaky bug in a for-loop and fix it in minutes.</p>



<p class="wp-block-paragraph">Why watch?</p>



<ul class="wp-block-list">
<li>Learn a beginner-friendly debugging technique that works in any language.</li>



<li>See real code examples with clear, relatable explanations.</li>



<li>Get tips to make your debug output readable and avoid hours of frustration.</li>



<li>Discover how to short circuit print statements for reusable debugging.</li>
</ul>



<p class="wp-block-paragraph">If you’re ready to level up your coding game and squash bugs like a champ, smash that play button! Don’t forget to subscribe and hit the bell for more coding tutorials, from beginner hacks to advanced tricks. Drop a comment if you’ve ever used caveman debugging or have a bug you need help with—I read every one! Check out my next video on using a proper debugger for even more debugging goodness.</p>



<p class="wp-block-paragraph">Scan the QR code on-screen or visit my website (linked below) for more tutorials, services, and coding resources. Let’s keep the coding community growing—your support means the world! #CavemanDebugging #CodingTips #DebuggingHacks</p>



<p class="wp-block-paragraph">Hey everybody! In this video I&#8217;m gonna try to familiarize you with a concept</p>



<p class="wp-block-paragraph">called caveman debugging. It&#8217;s just as bad as it sounds but it&#8217;s really really</p>



<p class="wp-block-paragraph">really useful. So suppose for the sake of argument you&#8217;re writing a program I&#8217;m</p>



<p class="wp-block-paragraph">gonna show a C++ program here but this this concept is not just for C++</p>



<p class="wp-block-paragraph">debugging it&#8217;s also for assembly and any other kind of language that you can come</p>



<p class="wp-block-paragraph">other kind of language that you can come up with but suppose I have a program and I&#8217;m trying to</p>



<p class="wp-block-paragraph">figure out why it&#8217;s not working so if you look at this program right here that I&#8217;ve kind of written</p>



<p class="wp-block-paragraph">up already we have a main function here and we have like a little hello message that&#8217;s not my</p>



<p class="wp-block-paragraph">name I love that name though and we have a variable a and then we just sort of do some nonsense to it</p>



<p class="wp-block-paragraph">to try and compute a value for a when I say nonsense I mean literally I&#8217;m just I just made</p>



<p class="wp-block-paragraph">I&#8217;m just I just made up instructions the point of this video is not to show you some advanced program</p>



<p class="wp-block-paragraph">It&#8217;s just to show you that you know</p>



<p class="wp-block-paragraph">This is how you can possibly debug a program that has gone awry</p>



<p class="wp-block-paragraph">So you can imagine at home that this code you&#8217;re seeing right here might be your larger project your larger</p>



<p class="wp-block-paragraph">Code base whatever it is that you&#8217;re doing that is not working for some reason and you&#8217;re not sure why</p>



<p class="wp-block-paragraph">So, um, let me run the program real fast</p>



<p class="wp-block-paragraph">It basically is just like a little for loop and then it just sort of</p>



<p class="wp-block-paragraph">of you know not randomly but it just kind of increases the value of a for no reason</p>



<p class="wp-block-paragraph">a bunch of times and then it calls a function that will crash later</p>



<p class="wp-block-paragraph">so let me show you what happens when we try to run this program okay do do do</p>



<p class="wp-block-paragraph">okay i want to go clear and make run if you don&#8217;t know how to do a make file or compile</p>



<p class="wp-block-paragraph">or link or anything like that uh then go see my other videos so clear and make run</p>



<p class="wp-block-paragraph">What did I do wrong?</p>



<p class="wp-block-paragraph">TempResult was not declared in this scope.</p>



<p class="wp-block-paragraph">Okay, well, this is now a video on reading compiler errors.</p>



<p class="wp-block-paragraph">Line 59, I probably left something out.</p>



<p class="wp-block-paragraph">Oh, because I just changed it.</p>



<p class="wp-block-paragraph">I forgot to put it back in there.</p>



<p class="wp-block-paragraph">Return tempResult, we should just return input times two.</p>



<p class="wp-block-paragraph">And I&#8217;m just making this up.</p>



<p class="wp-block-paragraph">It&#8217;s not really like a valid algorithm.</p>



<p class="wp-block-paragraph">Okay, so we run our program.</p>



<p class="wp-block-paragraph">We print the final result and we realize for some reason the final result is wrong.</p>



<p class="wp-block-paragraph">result is wrong. So I don&#8217;t, I mean, I just made this up. So I don&#8217;t really know what the right</p>



<p class="wp-block-paragraph">answer is. But just imagine that you are looking at some sort of an output, some sort of a final</p>



<p class="wp-block-paragraph">state, maybe a crash. And you realize, oh, my program doesn&#8217;t work, but it&#8217;s too complicated</p>



<p class="wp-block-paragraph">to figure out. Caveman debugging to the rescue. Caveman debugging kind of is as bad as it sounds.</p>



<p class="wp-block-paragraph">It&#8217;s just really, really simple. But it&#8217;s also really useful, especially if you just want to do</p>



<p class="wp-block-paragraph">on you don&#8217;t want to dive deep into a full-on debugger or do something more advanced it literally</p>



<p class="wp-block-paragraph">is just printing a lot of things while your program is running i do it all the time i usually</p>



<p class="wp-block-paragraph">don&#8217;t even go to a debugger unless i really get in trouble with like some huge mess um okay so</p>



<p class="wp-block-paragraph">the first thing i&#8217;m going to say is in this for loop we uh you know we&#8217;re kind of like iterating</p>



<p class="wp-block-paragraph">And so probably this is a good idea to announce that we&#8217;re iterating in the for loop.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to go Cout.</p>



<p class="wp-block-paragraph">In C++, you know, we have the Cout object that we can use to stream texts to standard output,</p>



<p class="wp-block-paragraph">which usually goes to the terminal.</p>



<p class="wp-block-paragraph">So use whatever construct you&#8217;re using for your particular language.</p>



<p class="wp-block-paragraph">So we&#8217;re going to do Cout.</p>



<p class="wp-block-paragraph">And I should say also, if you&#8217;re programming in assembly,</p>



<p class="wp-block-paragraph">if you are programming in assembly,</p>



<p class="wp-block-paragraph">it&#8217;s a little bit more complicated than just writing a Cout.</p>



<p class="wp-block-paragraph">little bit more complicated than just writing a C out you probably have to have some pre-computed</p>



<p class="wp-block-paragraph">messages and then you can use a library to print a number to the screen or use printf to print stuff</p>



<p class="wp-block-paragraph">to the screen but you can do it just takes a little bit longer so anyway conceptually I&#8217;m</p>



<p class="wp-block-paragraph">just going to say this is the first iteration of my loop so I&#8217;m going to sort of announce it I&#8217;m</p>



<p class="wp-block-paragraph">going to say main and then I&#8217;m going to call it main four or how about primary four or first four</p>



<p class="wp-block-paragraph">but I want to try to label the for loop.</p>



<p class="wp-block-paragraph">And maybe instead of leaving those parentheses blank,</p>



<p class="wp-block-paragraph">I could say iteration number i right there,</p>



<p class="wp-block-paragraph">or maybe I could do iteration i.</p>



<p class="wp-block-paragraph">That would be pretty good.</p>



<p class="wp-block-paragraph">Then I just have to replace the i with the actual variable i</p>



<p class="wp-block-paragraph">so that the i keeps increasing.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to like do another stream operator here</p>



<p class="wp-block-paragraph">and I&#8217;m going to say i.</p>



<p class="wp-block-paragraph">Then I&#8217;ll print a new line.</p>



<p class="wp-block-paragraph">we&#8217;ve got, you know, one iteration of our loop.</p>



<p class="wp-block-paragraph">Maybe I should also print what is the current value of A</p>



<p class="wp-block-paragraph">because the point of this, you know, weird nonsense code</p>



<p class="wp-block-paragraph">is we&#8217;re coming up with a value for A, right?</p>



<p class="wp-block-paragraph">So I should just print what A is at the top of each iteration of the for loop.</p>



<p class="wp-block-paragraph">So I&#8217;m going to say A is equal to, and then do another A at the end of it.</p>



<p class="wp-block-paragraph">And then maybe at the bottom of the for loop,</p>



<p class="wp-block-paragraph">when the for loop is actually ending one of its iterations,</p>



<p class="wp-block-paragraph">I can just say we&#8217;re at the bottom of the iteration so maybe I&#8217;ll put to end</p>



<p class="wp-block-paragraph">iteration and then print the final value of a and then at the top I&#8217;ll say begin</p>



<p class="wp-block-paragraph">iteration at this point you might start to feel like hey aren&#8217;t you using too</p>



<p class="wp-block-paragraph">many words here like why can&#8217;t I just print a bunch of numbers I mean you</p>



<p class="wp-block-paragraph">could but when you&#8217;re coding you need all the brainpower you can get to not</p>



<p class="wp-block-paragraph">just code but to debug coding is already hard enough without making it harder</p>



<p class="wp-block-paragraph">harder for yourself than you need it to be. So, you know, I see people all the time, they&#8217;re</p>



<p class="wp-block-paragraph">trying to debug their code and they just like start printing numbers. And after not very long</p>



<p class="wp-block-paragraph">at all, they&#8217;re looking at the debug output and they&#8217;re just like, what did that number mean?</p>



<p class="wp-block-paragraph">Where is the number I&#8217;m looking for? It&#8217;s just a bunch of numbers. It&#8217;s harder to debug when you</p>



<p class="wp-block-paragraph">do it that way. Do it the nice and pretty way. It just costs you a couple of extra keystrokes to do,</p>



<p class="wp-block-paragraph">you know, nice letters and new lines and things, nice words, labels. Isn&#8217;t that still a lot better</p>



<p class="wp-block-paragraph">Isn&#8217;t that still a lot better than debugging for an extra six hours?</p>



<p class="wp-block-paragraph">Because you can&#8217;t really understand what you&#8217;re seeing.</p>



<p class="wp-block-paragraph">Anyway, let me show you what this looks like so far with just those two lines added.</p>



<p class="wp-block-paragraph">Now we can kind of see, alright, alright, on iteration number 61, where I was 61, then</p>



<p class="wp-block-paragraph">this was the first value of A and then after that this was the second value of A, you know,</p>



<p class="wp-block-paragraph">when we were finished with the iteration.</p>



<p class="wp-block-paragraph">It seems to have gone up by a certain amount.</p>



<p class="wp-block-paragraph">you know it was like a negative blah blah blah 836 and then negative blah blah blah 708 so it</p>



<p class="wp-block-paragraph">kind of increased in value all right that&#8217;s a little bit helpful now it&#8217;s a really good uh</p>



<p class="wp-block-paragraph">place to uh print our decision points so anytime in your code where you have an if or an else or</p>



<p class="wp-block-paragraph">a function call or anything where you are kind of like you know making a decision or processing your</p>



<p class="wp-block-paragraph">data in some way it&#8217;s probably a good idea to announce your decisions so i could say up here i</p>



<p class="wp-block-paragraph">say up here i can go maybe i&#8217;ll say uh main first four and then i&#8217;ll call it uh maybe i&#8217;ll do a</p>



<p class="wp-block-paragraph">double colon there and i&#8217;ll say top if just to make it easy to read that i&#8217;m kind of like at</p>



<p class="wp-block-paragraph">the first if statement um maybe i&#8217;ll even put parentheses i&#8217;ll say a is more than 20 just to</p>



<p class="wp-block-paragraph">kind of like name what i&#8217;m actually doing and then i could replace the a with the actual value of a</p>



<p class="wp-block-paragraph">actual value of a so i could say a like that and maybe uh when i&#8217;m reading this later i might want</p>



<p class="wp-block-paragraph">to kind of actually see the variable name so i could say uh you could just like put a as a string</p>



<p class="wp-block-paragraph">and then maybe its value in parentheses or something like that do a new line um and then</p>



<p class="wp-block-paragraph">maybe after that top thing i&#8217;ll say uh true to indicate that we&#8217;re inside of the the if statement</p>



<p class="wp-block-paragraph">the if statement and then maybe at the bottom of that if statement we&#8217;ll just say</p>



<p class="wp-block-paragraph">a is now true and we&#8217;ll say like a is now you know whatever the new value of a was so just</p>



<p class="wp-block-paragraph">basically we&#8217;re announcing that we decided to go into this if block and then we announce what we</p>



<p class="wp-block-paragraph">ended up changing a to and also you probably anytime you see a compound expression like this</p>



<p class="wp-block-paragraph">You know B time something or a plus something or just you know a big part of multiple parts of the expression any expression</p>



<p class="wp-block-paragraph">That&#8217;s more than just like one variable or one number. It&#8217;s probably a good idea if you break that up into temporary variables, too</p>



<p class="wp-block-paragraph">and then</p>



<p class="wp-block-paragraph">Print out each variable and I know that&#8217;s a lot of stuff to read but again it beats debugging for an extra six hours</p>



<p class="wp-block-paragraph">I&#8217;m gonna leave that be for now though</p>



<p class="wp-block-paragraph">leave that be and</p>



<p class="wp-block-paragraph">I&#8217;m just gonna continue adding comments into the rest of the code. So I&#8217;m gonna do the second if block here</p>



<p class="wp-block-paragraph">So I&#8217;m going to do the second if block here.</p>



<p class="wp-block-paragraph">I&#8217;m going to say we&#8217;re in the first floor.</p>



<p class="wp-block-paragraph">We&#8217;re in the bottom if more than 20 true.</p>



<p class="wp-block-paragraph">And then we&#8217;ll print out what is the value of a after we&#8217;re finished.</p>



<p class="wp-block-paragraph">We&#8217;ll say a is now is now whatever value for a.</p>



<p class="wp-block-paragraph">And then I&#8217;ll do the same thing for this function call.</p>



<p class="wp-block-paragraph">Because, you know, when I call this function, it&#8217;s going to change the value somehow.</p>



<p class="wp-block-paragraph">So we&#8217;re going to do cout about to a plus equals f, you know, call to f.</p>



<p class="wp-block-paragraph">And then inside the arguments, I&#8217;m obviously putting i plus 3.</p>



<p class="wp-block-paragraph">But because i is a variable, we could just print that.</p>



<p class="wp-block-paragraph">So I&#8217;m going to do quote, quote, and then just stick the actual i in there.</p>



<p class="wp-block-paragraph">And then another new line.</p>



<p class="wp-block-paragraph">a finished a plus equals f and then I&#8217;ll just say you know a is now you know a you know print the</p>



<p class="wp-block-paragraph">new value of a you could also say a equal equal a and then print the value whatever you want but</p>



<p class="wp-block-paragraph">the point is I&#8217;m just printing everything here so now let&#8217;s go down a little bit more because</p>



<p class="wp-block-paragraph">there is a function call if you look at this function call down here here&#8217;s like some nonsense</p>



<p class="wp-block-paragraph">being used here&#8217;s some other like you know disabled code really what i&#8217;m doing at the</p>



<p class="wp-block-paragraph">very end is i&#8217;m just taking the input that the function received and i&#8217;m just multiplying it by</p>



<p class="wp-block-paragraph">two and returning it so again imagine that your code is a lot more complicated than this</p>



<p class="wp-block-paragraph">maybe input times two is actually input times two divided by three and then some other function</p>



<p class="wp-block-paragraph">call and then some other this and some other that and whatever so a lot of people will just kind of</p>



<p class="wp-block-paragraph">stuff like a really complicated expression in one line or one assignment or one return statement</p>



<p class="wp-block-paragraph">And that&#8217;s super confusing because you can&#8217;t really be sure that every part of the expression is as you thought.</p>



<p class="wp-block-paragraph">So it&#8217;s a really good idea to break it all up into parts and print each part.</p>



<p class="wp-block-paragraph">So you could imagine that we have like a C out here and we&#8217;ll say C out, you know, begin F.</p>



<p class="wp-block-paragraph">I&#8217;ll say like begin for F and then F receives an input of input.</p>



<p class="wp-block-paragraph">Do an end L.</p>



<p class="wp-block-paragraph">And then I&#8217;ll make a temporary variable here.</p>



<p class="wp-block-paragraph">variable here I&#8217;ll say int temp results equals input times two and then I&#8217;ll</p>



<p class="wp-block-paragraph">print that f and maybe I&#8217;ll do the input again</p>



<p class="wp-block-paragraph">temp result is now and then say temp result so I&#8217;m just gonna print what the</p>



<p class="wp-block-paragraph">temp result actually was and I could print something about I just multiplied</p>



<p class="wp-block-paragraph">thing about I just multiplied the input by two and then you know the more</p>



<p class="wp-block-paragraph">complicated your expression is the more temporary variables you want to use and</p>



<p class="wp-block-paragraph">just kind of print every single one of them and print you know this new</p>



<p class="wp-block-paragraph">variable is the result of dividing by two this new variable is the result of</p>



<p class="wp-block-paragraph">calling some other function and so forth</p>



<p class="wp-block-paragraph">so then we have like a basically you know basically a pretty good idea maybe</p>



<p class="wp-block-paragraph">at the end though instead of multiplying by two again you want to make it more</p>



<p class="wp-block-paragraph">want to make it more consistent with your debug output so like here temp result is obviously going</p>



<p class="wp-block-paragraph">to be the result that i return why would you do the expression all over again for the return part</p>



<p class="wp-block-paragraph">when you could easily get it wrong why not instead just return the temp result that you made right so</p>



<p class="wp-block-paragraph">then that way your output completely matches what you&#8217;re actually returning and for now i think</p>



<p class="wp-block-paragraph">that&#8217;s all we need to do let me run it one more time and then you&#8217;ll see a bunch of stuff now uh</p>



<p class="wp-block-paragraph">Now, we have a lot of information that we can use to trace how our program was thinking and hopefully find the problem.</p>



<p class="wp-block-paragraph">But isn&#8217;t this like a little bit starting to get a little bit hard to read, right?</p>



<p class="wp-block-paragraph">You can see that there are kind of blocks happening whenever we iterate.</p>



<p class="wp-block-paragraph">So, you know, for me, I always try to keep in mind you need all the brainpower you can get.</p>



<p class="wp-block-paragraph">Why not just format it a little bit better so it&#8217;s really easy to just quickly look at one block and see, you know,</p>



<p class="wp-block-paragraph">the couts kind of like belong together so i&#8217;m just going to add one more cout in the main for loop</p>



<p class="wp-block-paragraph">here just at the very bottom i&#8217;m going to go couts and l just so that i get a new line and if i run</p>



<p class="wp-block-paragraph">the program again notice how it&#8217;s easier to see the blocks like oh that&#8217;s clearly one iteration</p>



<p class="wp-block-paragraph">right here you know your mind just grabs onto it faster and that increases your brain power and</p>



<p class="wp-block-paragraph">makes it easier to debug and read the debug output so i can go all right all right okay so</p>



<p class="wp-block-paragraph">all right okay so we&#8217;re right up here oh around uh iteration um number 83 uh a was this number</p>



<p class="wp-block-paragraph">and then it got increased by uh this other number and the reason that that happened is because the</p>



<p class="wp-block-paragraph">function returned 172 so it basically increased it by 172 and then it ended up being that number</p>



<p class="wp-block-paragraph">oh okay i think i see what went wrong oh no right in this particular program if we scroll up just a</p>



<p class="wp-block-paragraph">little bit we can probably see that the integer is overflowing right the integer was getting bigger</p>



<p class="wp-block-paragraph">right the integer was getting bigger and bigger and bigger here and then eventually</p>



<p class="wp-block-paragraph">it jumped into the negative at some point so right here we can see oh okay when did this</p>



<p class="wp-block-paragraph">number become negative suppose we didn&#8217;t want it to be negative um what was this this is like</p>



<p class="wp-block-paragraph">a million this is a billion no wait wait wait this is uh no that&#8217;s a million right there so it&#8217;s like</p>



<p class="wp-block-paragraph">299 million and then it overflowed oh no no it didn&#8217;t it didn&#8217;t overflow it started at 299</p>



<p class="wp-block-paragraph">it started at 299 then at the bottom it was sitting at 899 million that&#8217;s kind of close to a billion</p>



<p class="wp-block-paragraph">and it did jump up from 300 million to 900 million so that&#8217;s a jump up of like 600 million</p>



<p class="wp-block-paragraph">oh you know it&#8217;s like kind of jumping up faster with each iteration oh and i&#8217;m using a 32-bit</p>



<p class="wp-block-paragraph">signed integer which has a maximum value of around 2 billion so now i could possibly realize at this</p>



<p class="wp-block-paragraph">the number is just like it became too big and I need to change my data type or I need to change</p>



<p class="wp-block-paragraph">my algorithm for some reason right so you can kind of get to the bottom of things pretty quickly</p>



<p class="wp-block-paragraph">so here&#8217;s another problem that people encounter when they&#8217;re using caveman debugging</p>



<p class="wp-block-paragraph">basically you you add all these cout statements or print statements or whatever you&#8217;re doing in</p>



<p class="wp-block-paragraph">whatever language you have and then when you&#8217;re finished you&#8217;re kind of like well I guess uh</p>



<p class="wp-block-paragraph">I need to delete all of these Couts because I don&#8217;t want all this you know</p>



<p class="wp-block-paragraph">Junk being printed in my program after I fix the problem or maybe you&#8217;re trying to debug a different part of your program</p>



<p class="wp-block-paragraph">So then you start commenting out all the print statements or you start</p>



<p class="wp-block-paragraph">You know deleting them or whatever and then whoops later on you realize maybe that part of my program</p>



<p class="wp-block-paragraph">Was not actually fixed and I have to add all the Couts all over again from scratch that costs time</p>



<p class="wp-block-paragraph">So that&#8217;s not fun. So here&#8217;s a trick that I like to use. It&#8217;s called a short circuit</p>



<p class="wp-block-paragraph">it&#8217;s called a short circuit it&#8217;s a sort of like a beginning C++ thing or just</p>



<p class="wp-block-paragraph">when you&#8217;re first learning how to use logical operators for boolean</p>



<p class="wp-block-paragraph">expressions so I&#8217;m gonna do a boolean and I&#8217;m just gonna name it after what</p>



<p class="wp-block-paragraph">problem I&#8217;m trying to solve so we could just call this you know main C outs or</p>



<p class="wp-block-paragraph">something like that let&#8217;s I don&#8217;t know primary problem I&#8217;ll call it primary</p>



<p class="wp-block-paragraph">the boolean as true because then what will happen is uh we can then short circuit all of the cout</p>



<p class="wp-block-paragraph">statements we can say primary problem couts and cout like that and the way the short circuit works</p>



<p class="wp-block-paragraph">works is if you have a logical and expression you can see right here we have two sides</p>



<p class="wp-block-paragraph">of that statement now one&#8217;s on the left which is just the boolean and one&#8217;s on the right which is</p>



<p class="wp-block-paragraph">have a logical and then you know one and zero is equal to zero true and false is equal to false so</p>



<p class="wp-block-paragraph">both things have to be true for the expression to evaluate to true which means if the first thing</p>



<p class="wp-block-paragraph">is false there&#8217;s no point in even looking at the second thing at all because if i if i set that to</p>



<p class="wp-block-paragraph">false then the second part the c out is it doesn&#8217;t matter the whole expression is going to evaluate</p>



<p class="wp-block-paragraph">to false anyway so uh the logical operator itself will just you know block out the rest of the</p>



<p class="wp-block-paragraph">you know, block out the rest of the statement.</p>



<p class="wp-block-paragraph">That&#8217;s called a short circuit.</p>



<p class="wp-block-paragraph">So I&#8217;m going to copy the short circuiting to all of my C out statements like this.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">And do that.</p>



<p class="wp-block-paragraph">And then the C out there.</p>



<p class="wp-block-paragraph">And I guess I&#8217;ll leave the final result there.</p>



<p class="wp-block-paragraph">And for the moment, you know, this is just a regular function.</p>



<p class="wp-block-paragraph">apply the short circuiting to this other f unless I do a separate boolean but</p>



<p class="wp-block-paragraph">keep in mind if this was a class and you had two different methods that you</p>



<p class="wp-block-paragraph">wanted to short circuit see outs inside of at the same time you could just use a</p>



<p class="wp-block-paragraph">member variable and name it after the problem you&#8217;re currently trying to solve</p>



<p class="wp-block-paragraph">and then just short circuit each see out in the appropriate method with that</p>



<p class="wp-block-paragraph">boolean so I guess in this regular program that doesn&#8217;t have a class I</p>



<p class="wp-block-paragraph">could move the boolean into the global if I wanted to but I&#8217;m not going to right</p>



<p class="wp-block-paragraph">if I wanted to, but I&#8217;m not going to right now.</p>



<p class="wp-block-paragraph">And if you&#8217;re writing assembly or some simpler language</p>



<p class="wp-block-paragraph">and you&#8217;re thinking, hey, I can&#8217;t short circuit an assembly</p>



<p class="wp-block-paragraph">or some other language, well, you could write a function</p>



<p class="wp-block-paragraph">that just takes a couple arguments.</p>



<p class="wp-block-paragraph">You could write a function that takes a string to print</p>



<p class="wp-block-paragraph">and maybe a number to print or just, you know,</p>



<p class="wp-block-paragraph">something simple like that.</p>



<p class="wp-block-paragraph">And then in the function itself that prints,</p>



<p class="wp-block-paragraph">you could call it debug print if you want.</p>



<p class="wp-block-paragraph">Have it look at a global variable or define</p>



<p class="wp-block-paragraph">that you&#8217;ve set up at the top of the assembly module.</p>



<p class="wp-block-paragraph">set up at the top of the assembly module, which you can just turn on and off,</p>



<p class="wp-block-paragraph">like just do a data byte and set it to a zero or set it to a one.</p>



<p class="wp-block-paragraph">And then the function debug print will just look at that variable to decide</p>



<p class="wp-block-paragraph">whether or not it&#8217;s going to actually print or not.</p>



<p class="wp-block-paragraph">So, you know, it&#8217;s a little more complicated in assembly,</p>



<p class="wp-block-paragraph">but you can do it basically the same concept.</p>



<p class="wp-block-paragraph">Let&#8217;s run this again just to make sure it still works.</p>



<p class="wp-block-paragraph">Okay, so it still works.</p>



<p class="wp-block-paragraph">So now suppose I want to turn off all the Cout statements.</p>



<p class="wp-block-paragraph">If I just change the true to false,</p>



<p class="wp-block-paragraph">the true to false notice how it&#8217;s all gone except for the stuff inside of f which i told you i</p>



<p class="wp-block-paragraph">wasn&#8217;t going to touch but notice how easy it was to mute it and then if i want to bring it back</p>



<p class="wp-block-paragraph">later i just go true to unmute it of course if you want to do a little bit more typing you can</p>



<p class="wp-block-paragraph">also do if statements like if this condition is true and that condition is true then print the</p>



<p class="wp-block-paragraph">debug statement so then you can have a more complicated way of muting and not muting but</p>



<p class="wp-block-paragraph">I&#8217;m going to leave it as is right now.</p>



<p class="wp-block-paragraph">Let&#8217;s see, what else do we got here?</p>



<p class="wp-block-paragraph">I think actually at this point, this is the basic idea of caveman debugging.</p>



<p class="wp-block-paragraph">Just basically print everything.</p>



<p class="wp-block-paragraph">Print all of your decision points.</p>



<p class="wp-block-paragraph">Use pretty labels that are really, really easy for you to understand.</p>



<p class="wp-block-paragraph">Use formatting so that your brain doesn&#8217;t have to struggle to understand what you&#8217;re seeing.</p>



<p class="wp-block-paragraph">If you just print a bunch of numbers, you&#8217;re going to be shooting yourself in the foot.</p>



<p class="wp-block-paragraph">you&#8217;re going to be shooting yourself in the foot and use short circuiting or if statements to</p>



<p class="wp-block-paragraph">selectively mute them so you can do less typing and and debugging the debugging and so forth but</p>



<p class="wp-block-paragraph">yeah i think i think this is all i really wanted to show you in this particular video</p>



<p class="wp-block-paragraph">i hope you feel like an expert in caveman debugging i certainly am and it you know it</p>



<p class="wp-block-paragraph">kind of fits my personality a little bit i&#8217;m like what&#8217;s going on um and like i said before</p>



<p class="wp-block-paragraph">debugger it&#8217;s probably a better idea but I usually don&#8217;t unless I&#8217;m in big trouble</p>



<p class="wp-block-paragraph">and I have a huge mess on my hands I usually just go directly to caveman</p>



<p class="wp-block-paragraph">debugging we&#8217;ll look at the same piece of code in my next video that I&#8217;m going</p>



<p class="wp-block-paragraph">to publish which is going to talk about using a proper debugger so watch the</p>



<p class="wp-block-paragraph">next one also but for now I hope you&#8217;ve enjoyed this video thank you for</p>



<p class="wp-block-paragraph">watching I hope you learned a little bit and had a little bit of fun see you in</p>



<p class="wp-block-paragraph">video</p>



<p class="wp-block-paragraph">whoops what the heck</p>



<p class="wp-block-paragraph">hey everybody thanks for watching this video again from the bottom of my heart</p>



<p class="wp-block-paragraph">i really appreciate it i do hope you did learn something and have</p>



<p class="wp-block-paragraph">some fun uh if you could do me a please a small little favor could you please</p>



<p class="wp-block-paragraph">subscribe and follow this channel or these videos</p>



<p class="wp-block-paragraph">or whatever it is you do on the current social media website that you&#8217;re looking</p>



<p class="wp-block-paragraph">at right now it would really mean the world to me and</p>



<p class="wp-block-paragraph">more videos and grow this community so we&#8217;ll be able to do more videos longer</p>



<p class="wp-block-paragraph">videos better videos or just I&#8217;ll be able to keep making videos in general so</p>



<p class="wp-block-paragraph">please do do me a kindness and and subscribe you know sometimes I&#8217;m</p>



<p class="wp-block-paragraph">sleeping in the middle of the night and I just wake up because I know somebody</p>



<p class="wp-block-paragraph">subscribed or followed it just wakes me up and I get filled with joy that&#8217;s</p>



<p class="wp-block-paragraph">exactly what happens every single time so you could do it as a nice favor to me</p>



<p class="wp-block-paragraph">or you could you control me if you want to just wake me up in the middle of the</p>



<p class="wp-block-paragraph">and then i&#8217;ll i&#8217;ll just wake up i promise that&#8217;s what will happen also uh if you look at the middle</p>



<p class="wp-block-paragraph">of the screen right now you should see a qr code which you can scan in order to go to the website</p>



<p class="wp-block-paragraph">which i think is also named somewhere at the bottom of this video and it&#8217;ll take you to my</p>



<p class="wp-block-paragraph">main website where you can just kind of like see all the videos i published and the services and</p>



<p class="wp-block-paragraph">tutorials and things that i offer and all that good stuff and uh if you have a suggestion for</p>



<p class="wp-block-paragraph">clarifications or errata or just future videos that you want to see please leave a comment or</p>



<p class="wp-block-paragraph">if you just want to say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever i also</p>



<p class="wp-block-paragraph">wake up for those in the middle of the night i get i wake up in a cold sweat and i&#8217;m like</p>



<p class="wp-block-paragraph">it would really it really mean the world to me i would really appreciate it so again thank you so</p>



<p class="wp-block-paragraph">much for watching this video and um enjoy the cool music as as i fade into the darkness which is</p>



<p class="wp-block-paragraph">us all.</p>



<p class="wp-block-paragraph">Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/caveman-debugging-simple-trick-to-debug-c-code-like-a-pro/">Caveman Debugging: Simple Trick to Debug C++ Code Like a Pro!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/caveman-debugging-simple-trick-to-debug-c-code-like-a-pro/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Compile, Link, Execute: A Beginner’s Guide to Linux Programming with C++, C, and Assembly</title>
		<link>https://www.NeuralLantern.com/compile-link-execute-a-beginners-guide-to-linux-programming-with-c-c-and-assembly/</link>
					<comments>https://www.NeuralLantern.com/compile-link-execute-a-beginners-guide-to-linux-programming-with-c-c-and-assembly/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Wed, 28 May 2025 03:37:23 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[assembly programming]]></category>
		<category><![CDATA[bash scripting]]></category>
		<category><![CDATA[beginner coding]]></category>
		<category><![CDATA[C programming]]></category>
		<category><![CDATA[coding tutorial]]></category>
		<category><![CDATA[compile C++]]></category>
		<category><![CDATA[execute Linux]]></category>
		<category><![CDATA[G++ tutorial]]></category>
		<category><![CDATA[link object files]]></category>
		<category><![CDATA[Linux compile script]]></category>
		<category><![CDATA[Linux development]]></category>
		<category><![CDATA[Linux programming]]></category>
		<category><![CDATA[name mangling]]></category>
		<category><![CDATA[object files]]></category>
		<category><![CDATA[programming basics]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=135</guid>

					<description><![CDATA[<p>Learn to compile, link &#038; execute C++, C, and assembly on Linux! Beginner-friendly guide with bash scripting tips. #Linux #Programming</p>
<p>The post <a href="https://www.NeuralLantern.com/compile-link-execute-a-beginners-guide-to-linux-programming-with-c-c-and-assembly/">Compile, Link, Execute: A Beginner’s Guide to Linux Programming with C++, C, and Assembly</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Compile, Link, Execute: A Beginner&#039;s Guide to Linux Programming with C++, C, and Assembly" width="1380" height="776" src="https://www.youtube.com/embed/z9iuTrptPM0?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Hey there, coding enthusiasts! Ready to master compiling, linking, and executing programs on Linux? In this fun and approachable video, we dive into the nuts and bolts of turning your code into runnable programs. We’ll create a simple C++ program, compile it with G++, and explore object files, linking, and execute permissions. Plus, we’ll mix in C and assembly code, tackle name mangling, and build a bash script to automate it all! Perfect for beginners or anyone curious about Linux programming, this guide is packed with practical tips and real-world examples. Don’t miss out—subscribe for more coding adventures, leave a comment with your thoughts, and let’s geek out together! Scan the QR code to visit my site for more tutorials. #LinuxProgramming #CodingForBeginners #CPlusPlus</p>



<p class="wp-block-paragraph">Introduction to Compiling, Linking, and Executing 00:00:00<br>Overview of the Process 00:00:05<br>Writing a Simple C++ Program 00:00:28<br>Compiling with G++ 00:02:01<br>Understanding Executable Files 00:03:04<br>Executing a Program 00:04:21<br>Handling Execute Permissions 00:05:13<br>Creating a Compile Script 00:07:00<br>Using Shebang for Scripts 00:08:43<br>Specifying Output Files 00:10:53<br>Breaking Down Compilation Steps 00:12:26<br>Compiling to Object Files 00:13:17<br>Linking Object Files 00:15:24<br>Handling Multiple Source Files 00:18:39<br>Mixing C and C++ with Name Mangling 00:22:52<br>Enhancing Script with Error Handling 00:24:29<br>Adding Assembly Source File 00:31:16<br>Using Bash Variables for Flags 00:41:53<br>Organizing Compiler Flags 00:44:41<br>Final Script Enhancements 00:46:36<br>Conclusion and Call to Action 00:47:35</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p class="wp-block-paragraph">Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hey there! Let&#8217;s talk about compiling, linking and executing.</p>



<p class="wp-block-paragraph">This video is going to focus on Linux, but I think it&#8217;ll be useful for all other operating systems that you might be working with at home.</p>



<p class="wp-block-paragraph">I&#8217;m just going to basically explain like what does it mean to compile?</p>



<p class="wp-block-paragraph">What does it mean to link a program?</p>



<p class="wp-block-paragraph">What does it mean to execute a program?</p>



<p class="wp-block-paragraph">If you don&#8217;t know that, then I think this video might be for you.</p>



<p class="wp-block-paragraph">Okay, so for starters, imagine you have written a program.</p>



<p class="wp-block-paragraph">I&#8217;m going to write the program here real fast.</p>



<p class="wp-block-paragraph">I&#8217;m going to say, let&#8217;s do an empty file.</p>



<p class="wp-block-paragraph">We&#8217;ll call it, let&#8217;s see, I got my answer key up here.</p>



<p class="wp-block-paragraph">We&#8217;ll call it first.cpp.</p>



<p class="wp-block-paragraph">First.cpp.</p>



<p class="wp-block-paragraph">So I&#8217;m just like making a first piece of source code and I&#8217;m editing it in my little editor.</p>



<p class="wp-block-paragraph">Notice how I&#8217;m not calling this the main.cpp program because a lot of beginners, they always</p>



<p class="wp-block-paragraph">do main.</p>



<p class="wp-block-paragraph">I want you to know that you don&#8217;t actually need a source code file called main.cpp.</p>



<p class="wp-block-paragraph">Even if you&#8217;re writing a C++ program, all you really need is just one instance of the function main.</p>



<p class="wp-block-paragraph">Beyond that also, you only need an instance of main if you&#8217;re writing a hybrid program</p>



<p class="wp-block-paragraph">or some kind of program that is in pure C++ or that has the GCC libraries.</p>



<p class="wp-block-paragraph">GCC libraries call on the main function as your entry point.</p>



<p class="wp-block-paragraph">But if you&#8217;re writing pure assembly, the entry point is actually underscore start as a label.</p>



<p class="wp-block-paragraph">We&#8217;re not really going to do this is not an assembly tutorial.</p>



<p class="wp-block-paragraph">I just wanted you to know real fast.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So I&#8217;m going to do like IO stream and then I&#8217;m going to say</p>



<p class="wp-block-paragraph">STDC out and I&#8217;m just going to print, you know, hello from first.</p>



<p class="wp-block-paragraph">Cpp.</p>



<p class="wp-block-paragraph">STD.</p>



<p class="wp-block-paragraph">And L.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So we kind of have like a hello world program that&#8217;ll just</p>



<p class="wp-block-paragraph">that&#8217;ll just basically print a message and do nothing else how do we compile</p>



<p class="wp-block-paragraph">this program and execute it you know what does that actually even mean okay</p>



<p class="wp-block-paragraph">so for starters the first thing that you probably do when you&#8217;re compiling a</p>



<p class="wp-block-paragraph">program you&#8217;ve probably been told to do something like this let me get my little</p>



<p class="wp-block-paragraph">command line open here you&#8217;ve probably been told to do something like this</p>



<p class="wp-block-paragraph">let&#8217;s compile with GCC or G++ and we&#8217;ll say the standard for C++ that we&#8217;re</p>



<p class="wp-block-paragraph">There are a bunch of other standards you can use.</p>



<p class="wp-block-paragraph">We can turn on all warnings.</p>



<p class="wp-block-paragraph">We can have the compiler be pedantic in terms of the warnings that it gives us.</p>



<p class="wp-block-paragraph">You know, these two things at the end don&#8217;t really matter that much.</p>



<p class="wp-block-paragraph">It&#8217;s really all about G++ and then STD C++ 23 to get it compiled.</p>



<p class="wp-block-paragraph">And then we&#8217;ll give an input file.</p>



<p class="wp-block-paragraph">We&#8217;ll say burst.cpp.</p>



<p class="wp-block-paragraph">And then I think probably usually this is where most of you stop.</p>



<p class="wp-block-paragraph">you stop we just kind of like specify a couple flags specify the input file then</p>



<p class="wp-block-paragraph">hit enter and it compiles if we list the contents of the directory now this might</p>



<p class="wp-block-paragraph">be familiar you&#8217;ll probably see something called a.out a.out notice how</p>



<p class="wp-block-paragraph">the permissions look a little bit different for that for that file it&#8217;s</p>



<p class="wp-block-paragraph">kind of printed in green in Ubuntu and if you look at the left side right here</p>



<p class="wp-block-paragraph">you can see that it&#8217;s got a bunch of X&#8217;s in the permissions area that just means</p>



<p class="wp-block-paragraph">That just means it has execute permission.</p>



<p class="wp-block-paragraph">The compiler does that automatically for you,</p>



<p class="wp-block-paragraph">but essentially this is like just, you know,</p>



<p class="wp-block-paragraph">an executable binary file.</p>



<p class="wp-block-paragraph">It&#8217;s not a text file.</p>



<p class="wp-block-paragraph">It&#8217;s just something that the computer is meant to run.</p>



<p class="wp-block-paragraph">We can look inside of it real fast.</p>



<p class="wp-block-paragraph">There&#8217;s a program called XXD on Linux,</p>



<p class="wp-block-paragraph">and it&#8217;ll sort of spill the contents of that file.</p>



<p class="wp-block-paragraph">So if I say XXD and then I go a.out,</p>



<p class="wp-block-paragraph">it just spills like a whole lot of like binary nonsense,</p>



<p class="wp-block-paragraph">right?</p>



<p class="wp-block-paragraph">you can see at the very beginning elf that&#8217;s uh i think that&#8217;s executable linking format</p>



<p class="wp-block-paragraph">for linux and then there&#8217;s like a bunch of stuff and it just doesn&#8217;t make sense this is not text</p>



<p class="wp-block-paragraph">that you can read here&#8217;s like some sort of a shared argument that it&#8217;s using and then some</p>



<p class="wp-block-paragraph">register information i don&#8217;t even know what most of this is somewhere in here if you look</p>



<p class="wp-block-paragraph">carefully you&#8217;ll probably see that message where is that oh yeah hello from c first.cpp so it&#8217;s</p>



<p class="wp-block-paragraph">saying that the message we typed in the program is actually embedded in the executable.</p>



<p class="wp-block-paragraph">That makes sense.</p>



<p class="wp-block-paragraph">So hopefully I&#8217;ve proved to you that this is just an executable program.</p>



<p class="wp-block-paragraph">How do you execute the program?</p>



<p class="wp-block-paragraph">Well, usually you&#8217;ll have to type, you know, the full path to the program that you want to execute</p>



<p class="wp-block-paragraph">because your custom program is not in the system library paths.</p>



<p class="wp-block-paragraph">So your system&#8217;s not going to know where to find it automatically,</p>



<p class="wp-block-paragraph">even if it&#8217;s in the current folder.</p>



<p class="wp-block-paragraph">So you would usually do something like, you know, the full path to your executable,</p>



<p class="wp-block-paragraph">path to your executable like a.out. But there&#8217;s a shortcut we can use in Linux. The dot directory</p>



<p class="wp-block-paragraph">usually just means or it always means the current directory. So if we say dot and then a slash,</p>



<p class="wp-block-paragraph">that&#8217;s the same thing as typing out the full path to the current directory. Then it&#8217;s really easy to</p>



<p class="wp-block-paragraph">just type the name of the file that we compiled. Okay, so a.out. We executed it now. So that&#8217;s what</p>



<p class="wp-block-paragraph">it means to execute. We just compiled without a lot of options. We&#8217;re going to try to do that better</p>



<p class="wp-block-paragraph">We&#8217;re going to try to do that better in a second.</p>



<p class="wp-block-paragraph">And we know that you need execute permissions.</p>



<p class="wp-block-paragraph">Let me show you what happens if we take away execute permissions.</p>



<p class="wp-block-paragraph">I&#8217;m going to use a command called chamad, like change the mode.</p>



<p class="wp-block-paragraph">I&#8217;m going to say take away execute permissions from the a.out program.</p>



<p class="wp-block-paragraph">Then if I list the directory again, notice how there are a bunch of X&#8217;s missing now</p>



<p class="wp-block-paragraph">on the left side of that a.out permissions area.</p>



<p class="wp-block-paragraph">Notice how it&#8217;s not in green anymore.</p>



<p class="wp-block-paragraph">Depending on your system, it might not be green or gray or whatever.</p>



<p class="wp-block-paragraph">be green or gray or whatever but just look at the permissions so now if i do a dot out</p>



<p class="wp-block-paragraph">it&#8217;ll say permission denied maybe you&#8217;ve seen this before especially if you&#8217;re syncing with</p>



<p class="wp-block-paragraph">the cloud that doesn&#8217;t carry execute permissions from one machine to another which happens to me</p>



<p class="wp-block-paragraph">all the time we can reverse this with just the chamad you know plus x execute permissions</p>



<p class="wp-block-paragraph">and then we can just execute it again the funny thing about execute permissions is</p>



<p class="wp-block-paragraph">you can actually execute a bash program which is basically a text file without</p>



<p class="wp-block-paragraph">without needing to execute a binary program so this is not a bash video I&#8217;ll</p>



<p class="wp-block-paragraph">make other videos in the future on my channels for for bash but for now just</p>



<p class="wp-block-paragraph">know that something you compile is not the only type of thing that you can</p>



<p class="wp-block-paragraph">actually execute in fact in Linux under the hood a lot of system tools are just</p>



<p class="wp-block-paragraph">written in bash or Python or something else that looks like a human readable</p>



<p class="wp-block-paragraph">like a human readable language and they are not necessarily all compiled languages, you</p>



<p class="wp-block-paragraph">know, like C++.</p>



<p class="wp-block-paragraph">Okay, so now that we kind of know that we&#8217;re compiling a program, let&#8217;s be a little bit</p>



<p class="wp-block-paragraph">better about specifying the name of the output file.</p>



<p class="wp-block-paragraph">So I just want you to see one more flag here and while I&#8217;m doing that, I&#8217;m going to create</p>



<p class="wp-block-paragraph">a script that will compile our program for us.</p>



<p class="wp-block-paragraph">nano and I&#8217;ll just name a file I&#8217;ll name it compile and it&#8217;ll be our compiler program okay</p>



<p class="wp-block-paragraph">so what we did before is it was I think G++ and then we named the standard is C++ 23 and then we</p>



<p class="wp-block-paragraph">said wall wall just means give me all warnings which is good to help your you know to help you</p>



<p class="wp-block-paragraph">write better code same thing for pedantic just helps you write better code it gives you more</p>



<p class="wp-block-paragraph">but you know it&#8217;s pretty good. Okay so this is where we stopped last time so</p>



<p class="wp-block-paragraph">I&#8217;m going to say now let me remove a dot out now instead of typing the command by</p>



<p class="wp-block-paragraph">ourselves we can run the compile script. The language I&#8217;ve just written was was</p>



<p class="wp-block-paragraph">well I haven&#8217;t really written in any particular language but if we use a</p>



<p class="wp-block-paragraph">shell interpreter called bash which is actually what&#8217;s running in the terminal</p>



<p class="wp-block-paragraph">right now it&#8217;ll interpret any command line that we give it as just something</p>



<p class="wp-block-paragraph">line that we give it as just something that we want it to execute to the system. So if I type</p>



<p class="wp-block-paragraph">bash to run the bash interpreter and I just specify the name of the script, it should compile the</p>



<p class="wp-block-paragraph">program automatically by executing that one line that I put inside of it. See now I&#8217;ve got the a.out</p>



<p class="wp-block-paragraph">again. If you rewind the video you&#8217;ll see the a.out wasn&#8217;t there when I originally ran it.</p>



<p class="wp-block-paragraph">One more time just to prove it to you. bash compile. Now you can see that it&#8217;s back. Okay</p>



<p class="wp-block-paragraph">Okay, so let&#8217;s make this compile program a little bit better instead of typing bash every single time</p>



<p class="wp-block-paragraph">I think I just want to try to execute the compile program directly. I</p>



<p class="wp-block-paragraph">Can do that pretty easily. There&#8217;s something in</p>



<p class="wp-block-paragraph">In our script that we can put that will designate what interpreter we should use to run the program</p>



<p class="wp-block-paragraph">So right now it&#8217;s just like some text and it doesn&#8217;t really mean anything</p>



<p class="wp-block-paragraph">there&#8217;s something called the shebang which just means hash bang and</p>



<p class="wp-block-paragraph">just provide the path to some interpreter. I&#8217;m going to type shebang and then a path</p>



<p class="wp-block-paragraph">to the bash interpreter. If you don&#8217;t know where bash is on your system, you can go which bash.</p>



<p class="wp-block-paragraph">And I guess mine is a user bin bash. I think I can get away with bin bash. Let me see.</p>



<p class="wp-block-paragraph">Let me just type it out to make sure bin bash. Yeah. Okay. So if I type exit, I&#8217;m actually in</p>



<p class="wp-block-paragraph">another version of bash, which is inside of bash. If I do exit, I should just kind of stay where I</p>



<p class="wp-block-paragraph">Okay, so bin bash will work, user bin bash will also work.</p>



<p class="wp-block-paragraph">I&#8217;m going to go back to editing this compiler program.</p>



<p class="wp-block-paragraph">And now all I have to do, because the system is going to know what interpreter to use to execute my little script program here,</p>



<p class="wp-block-paragraph">all I have to do is add execute permissions on it, and it should work.</p>



<p class="wp-block-paragraph">So let me first remove a dot out.</p>



<p class="wp-block-paragraph">And then let me try first to execute compile.</p>



<p class="wp-block-paragraph">It should not work because I don&#8217;t have execute permissions.</p>



<p class="wp-block-paragraph">Remember we talked about that before.</p>



<p class="wp-block-paragraph">permissions. Remember we talked about that before? So if I do that it says</p>



<p class="wp-block-paragraph">permission denied. Oh no! So I&#8217;m going to give it permission to execute. I&#8217;m going</p>



<p class="wp-block-paragraph">to say change the mode plus X on compile. If I list the directory again notice how</p>



<p class="wp-block-paragraph">it&#8217;s green notice how there&#8217;s a bunch of X&#8217;s everywhere. So now I should be able</p>



<p class="wp-block-paragraph">to just say compile and then it seems to have worked and notice how it has an</p>



<p class="wp-block-paragraph">because it&#8217;s a pain in the butt to type out all the compile commands every single time,</p>



<p class="wp-block-paragraph">especially if you have a complicated compile command or many files that you want to compile</p>



<p class="wp-block-paragraph">in the same shot. So, you know, of course, in another video, I&#8217;m going to talk about make files,</p>



<p class="wp-block-paragraph">build systems, proper build systems are a lot better than just making a script. But for now,</p>



<p class="wp-block-paragraph">let&#8217;s just make a script because I just want you to understand, you know, compiling, linking,</p>



<p class="wp-block-paragraph">some of the surrounding ideas. Okay, so I&#8217;m going to, let&#8217;s see, I&#8217;m going to go nano compile.</p>



<p class="wp-block-paragraph">And the next upgrade that I want to make is I want to specify the output file because it&#8217;s</p>



<p class="wp-block-paragraph">kind of a bad idea to not specify the output file and just hope that the compiler gives you</p>



<p class="wp-block-paragraph">the file that you wanted. I don&#8217;t know. So I&#8217;m going to do dash O main, and that&#8217;s going to give</p>



<p class="wp-block-paragraph">So if I remove a.out just to keep my area clean, I can now do compile.</p>



<p class="wp-block-paragraph">And if I list again, notice how I&#8217;ve got main.</p>



<p class="wp-block-paragraph">So I can execute main and it&#8217;s the same program that we already had.</p>



<p class="wp-block-paragraph">In fact, maybe sometimes just as a shortcut since this is a script,</p>



<p class="wp-block-paragraph">what if I&#8217;m always hitting ls-la, I always want to list the folder after I compile.</p>



<p class="wp-block-paragraph">I could just put that into the script.</p>



<p class="wp-block-paragraph">The more commands you put into the script, the more convenient things can get, unless</p>



<p class="wp-block-paragraph">I guess it gets too messy.</p>



<p class="wp-block-paragraph">So I&#8217;m going to do, I&#8217;m going to list first, and I&#8217;m going to remove main, just to prove</p>



<p class="wp-block-paragraph">to you that we&#8217;re doing this from scratch, and then I&#8217;ll do compile.</p>



<p class="wp-block-paragraph">Notice how it compiles and then lists everything for me.</p>



<p class="wp-block-paragraph">Seems like it didn&#8217;t actually turn the compile green.</p>



<p class="wp-block-paragraph">That&#8217;s probably another flag that we have to stick in there.</p>



<p class="wp-block-paragraph">Let me see if I can do that real fast.</p>



<p class="wp-block-paragraph">If not, I won&#8217;t waste time.</p>



<p class="wp-block-paragraph">This is not an LS video.</p>



<p class="wp-block-paragraph">probably color or colors is what I got to do. Let me just do that one more time. Yeah, okay. So</p>



<p class="wp-block-paragraph">that&#8217;s just a flag on LS. That&#8217;s not what this video is about. So now we&#8217;re compiling directly</p>



<p class="wp-block-paragraph">to main, but here&#8217;s the problem though. We&#8217;re actually kind of sort of skipping over some</p>



<p class="wp-block-paragraph">steps that we could be aware of. When we compile our program, we&#8217;re actually taking our source code</p>



<p class="wp-block-paragraph">and we&#8217;re assembling it down to assembly code under the hood, and then we&#8217;re compiling it to</p>



<p class="wp-block-paragraph">And then we&#8217;re compiling it to an object file, which is sort of just machine code.</p>



<p class="wp-block-paragraph">It&#8217;s like a level lower than assembly.</p>



<p class="wp-block-paragraph">And then as a last step, it&#8217;s getting linked into an executable named main.</p>



<p class="wp-block-paragraph">So we&#8217;re skipping a ton of steps.</p>



<p class="wp-block-paragraph">Really what&#8217;s supposed to be happening is every single source file.</p>



<p class="wp-block-paragraph">Oh, whoops.</p>



<p class="wp-block-paragraph">I&#8217;m on the wrong machine right now.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">Where&#8217;s that?</p>



<p class="wp-block-paragraph">Oh, the machine that I&#8217;m recording on.</p>



<p class="wp-block-paragraph">There we go.</p>



<p class="wp-block-paragraph">CPP and we&#8217;re thinking that it just goes directly to main you know that works if you only have one source file or if you don&#8217;t want to have</p>



<p class="wp-block-paragraph">fine-tuned control over your compiling</p>



<p class="wp-block-paragraph">But I would like to do something a little bit more detailed. Let&#8217;s compile our</p>



<p class="wp-block-paragraph">CPP source file into an object file. I&#8217;ll name it first.o and then we&#8217;ll link that into main</p>



<p class="wp-block-paragraph">Why is that useful because later when we have multiple source files?</p>



<p class="wp-block-paragraph">We might we might want to compile them all to object files first and then link them all together in one step into main</p>



<p class="wp-block-paragraph">all together in one step into main this will be even more useful when you later realize that you</p>



<p class="wp-block-paragraph">can use a build system that does kind of the same thing to save compilation time i won&#8217;t talk too</p>



<p class="wp-block-paragraph">much about make files here but let me just tell you when you start using a build system</p>



<p class="wp-block-paragraph">your compile time can be drastically reduced uh story i used to have a program a long time ago</p>



<p class="wp-block-paragraph">that i wrote myself took like an hour to compile i would literally every little change i made i&#8217;d</p>



<p class="wp-block-paragraph">have to get up and leave and go make a sandwich or something and then come back by the time it</p>



<p class="wp-block-paragraph">back by the time it was finished compiling when i started using object files as intermediate steps</p>



<p class="wp-block-paragraph">and upgraded to a build system i was using gnu make then my compile time went down to like a</p>



<p class="wp-block-paragraph">minute each time so it was like so much more efficient anyway let&#8217;s do that let&#8217;s do that now</p>



<p class="wp-block-paragraph">let&#8217;s let&#8217;s uh let&#8217;s nano our compile script and you just need another flag in here for the gcc</p>



<p class="wp-block-paragraph">an object file and not actually produce a fully linked executable that you can execute that means</p>



<p class="wp-block-paragraph">i should probably rename main to something else because main is supposed to be my executable at</p>



<p class="wp-block-paragraph">least that&#8217;s what i&#8217;ve chosen i would like to have every object file be named similarly to the source</p>



<p class="wp-block-paragraph">file it belongs to so i&#8217;m going to type the output now is going to be first.o and then the c flag</p>



<p class="wp-block-paragraph">just says only compile don&#8217;t link this means of course that i&#8217;m not going to produce a program</p>



<p class="wp-block-paragraph">a program that I can run. Let&#8217;s see, I&#8217;m gonna end up accidentally deleting the</p>



<p class="wp-block-paragraph">compiler. Okay, but we can see what we&#8217;re doing. Okay, so compile and CPP for first.</p>



<p class="wp-block-paragraph">So I&#8217;m gonna compile it and now notice how we have an object file and no main</p>



<p class="wp-block-paragraph">and just the source file and its corresponding object file. So I can&#8217;t run</p>



<p class="wp-block-paragraph">this program. I have to do the additional linking step now. So I&#8217;m gonna do</p>



<p class="wp-block-paragraph">step now so I&#8217;m going to do compile and in my editor here let&#8217;s see where is my</p>



<p class="wp-block-paragraph">command that I wanted to do for linking okay so I&#8217;m going to link with the the</p>



<p class="wp-block-paragraph">GCC libraries I&#8217;m gonna use the G++ command I&#8217;m just gonna put a couple of</p>



<p class="wp-block-paragraph">flags I&#8217;ll explain them real fast I&#8217;m gonna say that I want a 64-bit</p>



<p class="wp-block-paragraph">executable which you probably actually don&#8217;t have to specify I&#8217;m going to</p>



<p class="wp-block-paragraph">anyway and then I&#8217;m gonna tell it again that I want it to link up against the</p>



<p class="wp-block-paragraph">23 libraries. This is important if multiple modules reference the C++ libraries. I&#8217;m not</p>



<p class="wp-block-paragraph">even sure. I think I need it in both the compiling command and the linking command. I&#8217;m going to</p>



<p class="wp-block-paragraph">leave it in both because it should work. Usually if you want to embed debugging symbols into your</p>



<p class="wp-block-paragraph">program, you want to put a dash G there, which is a great idea. But we&#8217;re not going to talk about</p>



<p class="wp-block-paragraph">debugging in this video. You can also specify the type of debugging symbols that you want.</p>



<p class="wp-block-paragraph">symbols that you want I&#8217;m just gonna put that in here right now G dwarf 2 and</p>



<p class="wp-block-paragraph">then there&#8217;s some new flags that you kind of need there&#8217;s one here called no</p>



<p class="wp-block-paragraph">PI which I think is just an Ubuntu thing your program probably won&#8217;t execute if</p>



<p class="wp-block-paragraph">you don&#8217;t do that just just put it in there and trust me there&#8217;s another one</p>



<p class="wp-block-paragraph">that we have to put in now called no exec stack which basically prevents your</p>



<p class="wp-block-paragraph">program from executing code sitting inside of the stack which is just sort</p>



<p class="wp-block-paragraph">not get hacked hopefully it&#8217;s not bulletproof but you know it might help</p>



<p class="wp-block-paragraph">and then i&#8217;m going to give it input files the input files for the linking</p>



<p class="wp-block-paragraph">stage maybe i should do a comment linking stage</p>



<p class="wp-block-paragraph">compile the c++ program or source or something</p>



<p class="wp-block-paragraph">for the linking stage uh you want to you want to provide all of the object files</p>



<p class="wp-block-paragraph">that you&#8217;re going to link together in this case we just have you know</p>



<p class="wp-block-paragraph">file named first and then we can specify the output file as main if we didn&#8217;t</p>



<p class="wp-block-paragraph">specify it would probably be a dot out like we saw before so if I got this</p>



<p class="wp-block-paragraph">right let&#8217;s see if I did now this should compile the C++ source code file into</p>



<p class="wp-block-paragraph">its corresponding object file and then scoop up the object file turn it into an</p>



<p class="wp-block-paragraph">executable okay so my clear and then list and then I&#8217;m gonna remove the object</p>



<p class="wp-block-paragraph">put star dot o which is a shell trick to basically say that that star dot o is</p>



<p class="wp-block-paragraph">going to expand to really mean every file that ends in dot o so you know in</p>



<p class="wp-block-paragraph">this case it&#8217;s actually just gonna end up being first dot o but it&#8217;s a trick you</p>



<p class="wp-block-paragraph">can use to grab multiple object files or files of a certain type all in one</p>



<p class="wp-block-paragraph">command so I&#8217;m gonna do that and then I&#8217;m gonna list again and then I&#8217;m gonna</p>



<p class="wp-block-paragraph">compile and you can see that the compile command it created first dot o the</p>



<p class="wp-block-paragraph">the object file, and it also created the executable main.</p>



<p class="wp-block-paragraph">So if I execute main, the same thing should happen.</p>



<p class="wp-block-paragraph">So great. We&#8217;re ready to move on to another step.</p>



<p class="wp-block-paragraph">Let me remove star dot O.</p>



<p class="wp-block-paragraph">I got to be so careful because I&#8217;m going to totally ruin this video by erasing the wrong thing.</p>



<p class="wp-block-paragraph">Okay. Because this is, I should be in a Git repository, but I&#8217;m trying to be fast here.</p>



<p class="wp-block-paragraph">Okay. So let&#8217;s nano compile.</p>



<p class="wp-block-paragraph">Let&#8217;s create a second source file actually.</p>



<p class="wp-block-paragraph">Okay. So let me get out of this.</p>



<p class="wp-block-paragraph">Let me get out of this.</p>



<p class="wp-block-paragraph">I want to create a second source file.</p>



<p class="wp-block-paragraph">I&#8217;m going to call it second.c.</p>



<p class="wp-block-paragraph">It&#8217;s going to be a pure C program.</p>



<p class="wp-block-paragraph">And because we don&#8217;t have C++ libraries in C source files,</p>



<p class="wp-block-paragraph">I&#8217;m just going to say, you know,</p>



<p class="wp-block-paragraph">standard input output dot O for the header.</p>



<p class="wp-block-paragraph">I&#8217;m going to make a function called void second probably.</p>



<p class="wp-block-paragraph">And it doesn&#8217;t do anything except just sort of print</p>



<p class="wp-block-paragraph">a little message.</p>



<p class="wp-block-paragraph">So I&#8217;m going to say hello from second.</p>



<p class="wp-block-paragraph">And then do a new line.</p>



<p class="wp-block-paragraph">because we don&#8217;t have endels in c all right i think that&#8217;s probably going to work so then</p>



<p class="wp-block-paragraph">let&#8217;s uh edit our compiling script and we&#8217;ll just add another line here to compile the c source</p>



<p class="wp-block-paragraph">okay so i&#8217;m going to go gcc because it&#8217;s not c plus plus anymore and um i&#8217;m going to do all</p>



<p class="wp-block-paragraph">warnings and pedantic again uh you don&#8217;t really need even need to worry about that and i&#8217;m going</p>



<p class="wp-block-paragraph">need even need to worry about that and i&#8217;m going to give it an input of second.c because that&#8217;s the</p>



<p class="wp-block-paragraph">file we just worked on and i&#8217;m going to tell it i only want you to compile with the dash c flag if i</p>



<p class="wp-block-paragraph">forgot that on this one then i&#8217;ll probably end up with an object file a main and then an a.out that&#8217;s</p>



<p class="wp-block-paragraph">only based on the c source code and that probably wouldn&#8217;t work because the second source code</p>



<p class="wp-block-paragraph">doesn&#8217;t have a main function inside of it so um let&#8217;s see we&#8217;ll do output and it&#8217;s going to be</p>



<p class="wp-block-paragraph">and then I think that should be okay you know something that I just realized I</p>



<p class="wp-block-paragraph">should mention too is when you&#8217;re making hybrid programs like this or or</p>



<p class="wp-block-paragraph">programs where there are just many many source files like I said before you</p>



<p class="wp-block-paragraph">don&#8217;t need to have a source code named main.cpp you can name all your source</p>



<p class="wp-block-paragraph">codes anything that you want the one thing that you really do need is a piece</p>



<p class="wp-block-paragraph">of source code oh I&#8217;m editing inside the terminal suddenly sorry I got</p>



<p class="wp-block-paragraph">Sorry, I got sidetracked.</p>



<p class="wp-block-paragraph">I wanted to edit all this stuff inside of Genie because it&#8217;s a little bit better.</p>



<p class="wp-block-paragraph">Maybe it doesn&#8217;t matter.</p>



<p class="wp-block-paragraph">So notice how we have the main function inside of our first.cpp program,</p>



<p class="wp-block-paragraph">and then there&#8217;s no main function inside of our other source codes.</p>



<p class="wp-block-paragraph">For your program that uses the GCC libraries, you need exactly one instance of main.</p>



<p class="wp-block-paragraph">so that means um you know you have to have at least one and if you have more than one it&#8217;s</p>



<p class="wp-block-paragraph">probably not going to link so if i put a main inside of here probably not going to work</p>



<p class="wp-block-paragraph">this also kind of means you can arrange your source code in a funny way you could</p>



<p class="wp-block-paragraph">have a bunch of different pieces of source code that you could consider maybe libraries maybe</p>



<p class="wp-block-paragraph">there are a bunch of classes or something that will help your program and you can release multiple</p>



<p class="wp-block-paragraph">different executable files by just having different source code files each with their own</p>



<p class="wp-block-paragraph">mains and linked separately against the object files that contain your library or classes or</p>



<p class="wp-block-paragraph">whatever that&#8217;s just a little side tip but um anyway let&#8217;s see if i actually did this right</p>



<p class="wp-block-paragraph">we&#8217;re linking this and i&#8217;m going to see if it works i get stuck inside of the terminal i start</p>



<p class="wp-block-paragraph">thinking i&#8217;m going to edit everything inside there okay so it compiled well let me let me</p>



<p class="wp-block-paragraph">remove the main and then just clear it again in the list okay so now I&#8217;m gonna</p>



<p class="wp-block-paragraph">run the compiler and after the compiler ran everything seemed to be okay it</p>



<p class="wp-block-paragraph">compiled first into its object file and it also compiled second into its object</p>



<p class="wp-block-paragraph">file if I run the main executable notice how it only prints hello from first dot</p>



<p class="wp-block-paragraph">CPP well what about the second one that we just added well what we need to do is</p>



<p class="wp-block-paragraph">improve our linking stage notice how in the linking stage right here we just</p>



<p class="wp-block-paragraph">stage right here we just only link first.o so we should also include the other object file that we</p>



<p class="wp-block-paragraph">want i&#8217;m going to glob that in a second but uh let me show you compile now if we run main</p>



<p class="wp-block-paragraph">what did i do wrong hold on let&#8217;s see here second.c oh i forgot to actually call the second</p>



<p class="wp-block-paragraph">function so that&#8217;s cool just uh wrote a bunch of stuff for no reason at all let me uh let me have</p>



<p class="wp-block-paragraph">have the main function call on the second function we&#8217;re going to encounter an issue here too the</p>



<p class="wp-block-paragraph">second function is written in c and the first function uh its its source code is in c plus plus</p>



<p class="wp-block-paragraph">and the thing is c plus plus uses something called name mangling i won&#8217;t go over it too much in this</p>



<p class="wp-block-paragraph">video but it uses name mangling so you can overload functions you can have functions with the same</p>



<p class="wp-block-paragraph">name but like different signatures right so it&#8217;ll go in there and it&#8217;ll mangle the name of a function</p>



<p class="wp-block-paragraph">the name of a function according to its overload prototype so that we can actually call overloaded</p>



<p class="wp-block-paragraph">functions but we don&#8217;t really have that in C so that means if we try to call a C function</p>



<p class="wp-block-paragraph">from C++ we&#8217;re probably going to end up calling the wrong name because there&#8217;s the expectation</p>



<p class="wp-block-paragraph">that the other module has name mangling enabled but it&#8217;s not because it&#8217;s C so I just have</p>



<p class="wp-block-paragraph">to do this little block extern C and just name all the stuff that is not going to be</p>



<p class="wp-block-paragraph">name mangled i&#8217;ll just provide the prototypes of all the functions that i want to be able to call</p>



<p class="wp-block-paragraph">so just void second if you look here again we just have void second and now when um when the c plus</p>



<p class="wp-block-paragraph">plus module calls on second it won&#8217;t expect name mangling so it should work so we&#8217;re calling it</p>



<p class="wp-block-paragraph">and then we linked it now everything i think should be okay i&#8217;m going to compile one more time</p>



<p class="wp-block-paragraph">and then i&#8217;m going to run the main program and now you see that we have both calls in there</p>



<p class="wp-block-paragraph">Awesome. Let&#8217;s give this script a little bit more output though. This is kind of</p>



<p class="wp-block-paragraph">precarious. What if something failed inside of there? Maybe you don&#8217;t want the script to continue</p>



<p class="wp-block-paragraph">if something fails and maybe you kind of want to know where the script is at while it&#8217;s compiling.</p>



<p class="wp-block-paragraph">So I&#8217;m going to upgrade it just a little bit. So compile the source. I&#8217;m just going to say echo</p>



<p class="wp-block-paragraph">compiling the, you know, compiling burst.cbp. And then here I&#8217;ll just do another echo and I&#8217;ll say</p>



<p class="wp-block-paragraph">and then here I&#8217;ll say echo linking the executable or the binary aka the binary</p>



<p class="wp-block-paragraph">I don&#8217;t even know if that&#8217;s the proper term I just like to call these things binaries because</p>



<p class="wp-block-paragraph">they&#8217;re not in text anyway so if we do another I&#8217;m going to do I&#8217;m going to do a compound</p>



<p class="wp-block-paragraph">command line here I&#8217;m going to go clear and compile so that I don&#8217;t have to continue to</p>



<p class="wp-block-paragraph">continue to clear every single time. Now notice how it prints what it&#8217;s doing. So if it kind of</p>



<p class="wp-block-paragraph">failed somewhere along the way, or if it took a long time, you&#8217;d kind of know what&#8217;s going on.</p>



<p class="wp-block-paragraph">Now let&#8217;s use a little bash trick, because remember this is a bash script. It&#8217;s not just</p>



<p class="wp-block-paragraph">going to only execute actual commands. I&#8217;m going to say or exit with the return code of the previous</p>



<p class="wp-block-paragraph">We&#8217;re going to try to execute G++.</p>



<p class="wp-block-paragraph">If G++ fails for some reason, then the whole program or the whole script is going to exit</p>



<p class="wp-block-paragraph">and it&#8217;s going to exit with the return code mentioned here.</p>



<p class="wp-block-paragraph">I think it&#8217;s not going to print it.</p>



<p class="wp-block-paragraph">I&#8217;ll show you how to print it in a second, but we can actually make a function called</p>



<p class="wp-block-paragraph">die up here in a second, which might be better.</p>



<p class="wp-block-paragraph">So I&#8217;m going to do the same thing over here.</p>



<p class="wp-block-paragraph">I&#8217;m going to say or exit with the return code of the GCC command and then here or exit with</p>



<p class="wp-block-paragraph">And then here or exit with the return code of the linking command.</p>



<p class="wp-block-paragraph">We&#8217;ll do it one more time here.</p>



<p class="wp-block-paragraph">Notice how it seems to work.</p>



<p class="wp-block-paragraph">So now let&#8217;s make the first C++ program not actually compile.</p>



<p class="wp-block-paragraph">I&#8217;ll put a bunch of Zs there.</p>



<p class="wp-block-paragraph">And so if we try to compile it again, it should just quit right after it tries to compile the C++ program.</p>



<p class="wp-block-paragraph">So that saves you some time and helps draw your attention to what went wrong.</p>



<p class="wp-block-paragraph">The C++ compiler is saying hey, there&#8217;s like a type there. It doesn&#8217;t show the exit code though. So let&#8217;s make a function in bash</p>



<p class="wp-block-paragraph">That will die and print an exit code. So I&#8217;m going to say do die or maybe just die by itself something like that</p>



<p class="wp-block-paragraph">Functions whoops. I&#8217;m in the wrong language</p>



<p class="wp-block-paragraph">Let me go back to the compiler</p>



<p class="wp-block-paragraph">make a function in bash</p>



<p class="wp-block-paragraph">Called die and it&#8217;ll take one argument and the argument will just be the exit code</p>



<p class="wp-block-paragraph">that we want it to alert us of.</p>



<p class="wp-block-paragraph">So I&#8217;m going to say echo,</p>



<p class="wp-block-paragraph">I&#8217;m going to say we are dying now.</p>



<p class="wp-block-paragraph">Previous exits code was,</p>



<p class="wp-block-paragraph">maybe I&#8217;ll do a little variable here,</p>



<p class="wp-block-paragraph">I&#8217;ll do a local variable.</p>



<p class="wp-block-paragraph">Exit code is going to be the first incoming argument.</p>



<p class="wp-block-paragraph">This is a bash program, not C++.</p>



<p class="wp-block-paragraph">And then here I can just say exit code.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So then after writing all that,</p>



<p class="wp-block-paragraph">then after writing all that I can say or die and then just you know so I&#8217;m calling</p>



<p class="wp-block-paragraph">a function and the first argument I&#8217;m giving it is the actual exit code of the</p>



<p class="wp-block-paragraph">thing that died so we&#8217;re just kind of like using indirection to print a pretty</p>



<p class="wp-block-paragraph">pretty message to get a little bit more information so we&#8217;ll try that one more</p>



<p class="wp-block-paragraph">time notice how it says we are dying now previous exit code was one so that just</p>



<p class="wp-block-paragraph">that just tells us that gcc exited with the exit code of one not super useful but it&#8217;s nice to see</p>



<p class="wp-block-paragraph">could be something else entirely like i don&#8217;t know maybe uh maybe we misname the first source</p>



<p class="wp-block-paragraph">code file let&#8217;s see if the code changes i think it probably will nope maybe this exit code was one</p>



<p class="wp-block-paragraph">no such file or directory all right exit code am i doing something wrong i guess i&#8217;m all right</p>



<p class="wp-block-paragraph">Alright, okay, so let&#8217;s just move on.</p>



<p class="wp-block-paragraph">I wanted it to be fancier.</p>



<p class="wp-block-paragraph">We could also upgrade a little bit if we wanted to.</p>



<p class="wp-block-paragraph">Instead of echoing, I could make a function called log here,</p>



<p class="wp-block-paragraph">and I could just say that the log command just echoes,</p>



<p class="wp-block-paragraph">and maybe we&#8217;ll put a cute label, and we&#8217;ll say, you know,</p>



<p class="wp-block-paragraph">my super cool program compiler, or how about super cool compiler?</p>



<p class="wp-block-paragraph">And then just do the $1, because that&#8217;s the first incoming argument that you get.</p>



<p class="wp-block-paragraph">the first incoming argument that you get now I can type log instead of echo so</p>



<p class="wp-block-paragraph">that&#8217;s nice and why would you want to do this well now it&#8217;s gonna go inside of a</p>



<p class="wp-block-paragraph">function which means later on you can start adding extra commands like logger</p>



<p class="wp-block-paragraph">a log to the system daemon oh no so this would write to your system log in</p>



<p class="wp-block-paragraph">addition to printing something you could do anything you want you know it&#8217;s just</p>



<p class="wp-block-paragraph">like a regular program adding more power by sticking everything inside of</p>



<p class="wp-block-paragraph">functions I&#8217;m gonna put log here and let&#8217;s see if it works</p>



<p class="wp-block-paragraph">let&#8217;s see if it works pile okay nice notice how we have a little message with a little header which</p>



<p class="wp-block-paragraph">seems pretty cool maybe instead of echoing here let&#8217;s make a complaint function let&#8217;s do a</p>



<p class="wp-block-paragraph">complain and same thing as the echo function but maybe I think there&#8217;s a flag where you can tell</p>



<p class="wp-block-paragraph">echo to print to standard error instead of standard output but I&#8217;m just going to do it the easy way</p>



<p class="wp-block-paragraph">it the easy way I&#8217;m going to say one goes to two so that the the first pipe standard output is going</p>



<p class="wp-block-paragraph">to be redirected into the second pipe standard error so now I can use complain instead of um</p>



<p class="wp-block-paragraph">echo down here complain before I die oh I forgot to actually</p>



<p class="wp-block-paragraph">or die I forgot to actually exit so that means it was oh yeah it&#8217;s still compiling everything</p>



<p class="wp-block-paragraph">Let me fix that.</p>



<p class="wp-block-paragraph">So in the actual die function, hopefully you were at home cringing along with me.</p>



<p class="wp-block-paragraph">Let&#8217;s see, let&#8217;s exit with the actual exit code that was specified just to make things</p>



<p class="wp-block-paragraph">a little bit more automatable.</p>



<p class="wp-block-paragraph">Yeah, now it stops right away.</p>



<p class="wp-block-paragraph">And the complainer is like, you know, pretty cool.</p>



<p class="wp-block-paragraph">Let me fix the first source code real fast.</p>



<p class="wp-block-paragraph">And we&#8217;ll say that the second source code is broken.</p>



<p class="wp-block-paragraph">We&#8217;ll put a bunch of Z&#8217;s there.</p>



<p class="wp-block-paragraph">So now the first one compiles, the second one, it breaks.</p>



<p class="wp-block-paragraph">And we&#8217;re starting to, you know, get a hang for a compiler script that&#8217;s a lot more sophisticated</p>



<p class="wp-block-paragraph">than just typing things on the command line, right?</p>



<p class="wp-block-paragraph">You can take this as far as you want.</p>



<p class="wp-block-paragraph">The next step above this is using a proper build engine.</p>



<p class="wp-block-paragraph">So let&#8217;s see.</p>



<p class="wp-block-paragraph">Well, let&#8217;s do another source code.</p>



<p class="wp-block-paragraph">an assembly source code. So we&#8217;ll say third dot ASM and it&#8217;s just going to be Yasm. This is not</p>



<p class="wp-block-paragraph">a Yasm or assembly tutorial. I&#8217;m just showing you how to, you know, build a, you know, compile,</p>



<p class="wp-block-paragraph">link and execute. We&#8217;ll make a data section so I can just stick some defines in here real fast.</p>



<p class="wp-block-paragraph">I&#8217;ll say system write is going to be equal to a one and then the file descriptor for std out</p>



<p class="wp-block-paragraph">Do you ever feel like red jumps out at you on the screen?</p>



<p class="wp-block-paragraph">Does that mean I have eye problems?</p>



<p class="wp-block-paragraph">I am kind of old now.</p>



<p class="wp-block-paragraph">I don&#8217;t know.</p>



<p class="wp-block-paragraph">Hello from third dot ASM and I&#8217;ll just put a little new line there.</p>



<p class="wp-block-paragraph">So I don&#8217;t have to do it elsewhere.</p>



<p class="wp-block-paragraph">And then I&#8217;ll have to specify the magic message length because this is not a sophisticated program that can loop through the message looking for a null terminator.</p>



<p class="wp-block-paragraph">And then I&#8217;ll do a text section, which is where your code goes.</p>



<p class="wp-block-paragraph">which is where your code goes and you know in hybrid programs if I have this</p>



<p class="wp-block-paragraph">third function which is marked as a which is marked using a label and then</p>



<p class="wp-block-paragraph">in return statement I still have to mark a third as being accessible outside</p>



<p class="wp-block-paragraph">this module so I&#8217;m going to do the global statement and then I&#8217;m just going</p>



<p class="wp-block-paragraph">to do really quickly I&#8217;m going to move something into RAX it&#8217;s going to be</p>



<p class="wp-block-paragraph">system right so basically I would like to write something somewhere to some</p>



<p class="wp-block-paragraph">some file descriptor its first argument wants where I want to write it so I&#8217;m</p>



<p class="wp-block-paragraph">gonna write it to the standard output instead of an actual file and then I&#8217;m</p>



<p class="wp-block-paragraph">gonna move RSI the next argument is going to be the actual message or a</p>



<p class="wp-block-paragraph">pointer to the message that I defined above and you know check out my other</p>



<p class="wp-block-paragraph">videos if you want to learn assembly that&#8217;s this is not this is not an</p>



<p class="wp-block-paragraph">assembly learning video I&#8217;m just kind of doing it real fast in case you&#8217;re</p>



<p class="wp-block-paragraph">probably unless I ruined it somehow let&#8217;s start compiling or assembling the</p>



<p class="wp-block-paragraph">assembly program so just one more we&#8217;ll say assemble the assembly source or</p>



<p class="wp-block-paragraph">module or whatever you want to call it we&#8217;re going to use the ASM to do that</p>



<p class="wp-block-paragraph">G dwarf 2 is the debugging symbols not necessary in this video the format is I</p>



<p class="wp-block-paragraph">want a 64-bit executable that&#8217;s how you do it in Yasm and I&#8217;m going to give it</p>



<p class="wp-block-paragraph">and I&#8217;m going to give it an input of just the third assembly source file.</p>



<p class="wp-block-paragraph">And I want it to output the third object file.</p>



<p class="wp-block-paragraph">I got to remind myself to glob line 36 after this or die with the exit code.</p>



<p class="wp-block-paragraph">Okay. So now this might work.</p>



<p class="wp-block-paragraph">Oh, I got to put, I got to put third dot O in the linking stage.</p>



<p class="wp-block-paragraph">I&#8217;m going to do clear and I&#8217;m going to go here and compile.</p>



<p class="wp-block-paragraph">and compile.</p>



<p class="wp-block-paragraph">Unrecognized debug format, dward.</p>



<p class="wp-block-paragraph">Why didn&#8217;t you stop me?</p>



<p class="wp-block-paragraph">It&#8217;s g dwarf.</p>



<p class="wp-block-paragraph">Let&#8217;s see, what did I do wrong?</p>



<p class="wp-block-paragraph">g dwarf, oh, dwarf dash two.</p>



<p class="wp-block-paragraph">Oh, it&#8217;s not even g, it&#8217;s just dwarf two.</p>



<p class="wp-block-paragraph">Sorry.</p>



<p class="wp-block-paragraph">And I got to put a dash, I think, for EASM.</p>



<p class="wp-block-paragraph">Yeah, okay.</p>



<p class="wp-block-paragraph">Let&#8217;s see if that works.</p>



<p class="wp-block-paragraph">What did I do wrong?</p>



<p class="wp-block-paragraph">Oh no no, Yasm doesn&#8217;t need the dash, but GCC wants the dash.</p>



<p class="wp-block-paragraph">Okay, I had it right the first time.</p>



<p class="wp-block-paragraph">Doop doop doop, okay, so it probably linked.</p>



<p class="wp-block-paragraph">Let me run it and see what happened.</p>



<p class="wp-block-paragraph">Hello from the second, oh, we still have to actually call it from the C++ module.</p>



<p class="wp-block-paragraph">So now we&#8217;ll do the same thing.</p>



<p class="wp-block-paragraph">We&#8217;ll say that the assembly module, it&#8217;s not going to use name mangling.</p>



<p class="wp-block-paragraph">use name mangling there&#8217;s no overloads so we&#8217;re going to put it into the extern C</p>



<p class="wp-block-paragraph">block and we&#8217;ll just say you know void third how do we know that&#8217;s that it&#8217;s a</p>



<p class="wp-block-paragraph">void function with no arguments well you know that&#8217;s just a convenience that</p>



<p class="wp-block-paragraph">happens under the hood with C and C++ in assembly it&#8217;s just a label that you&#8217;re</p>



<p class="wp-block-paragraph">jumping to and returning from void means return type all that means is I&#8217;m</p>



<p class="wp-block-paragraph">trying my best not to make this a C++ or an assembly tutorial but all that</p>



<p class="wp-block-paragraph">All that means is there is no return value getting returned.</p>



<p class="wp-block-paragraph">That would be the RAX register if I wanted to move something in there.</p>



<p class="wp-block-paragraph">And then similarly, if I wanted to catch arguments, I&#8217;d be grabbing from other registers.</p>



<p class="wp-block-paragraph">So I&#8217;m not grabbing any register, any arguments from registers, and I&#8217;m not sending a value back with RAX or XMM0 or anything.</p>



<p class="wp-block-paragraph">So that just means it&#8217;s void and no arguments.</p>



<p class="wp-block-paragraph">So let&#8217;s do it again.</p>



<p class="wp-block-paragraph">Compile it and then run main.</p>



<p class="wp-block-paragraph">then run main hello from second oh i sure put in the name mingling thing but i forgot to call it</p>



<p class="wp-block-paragraph">let me do that third so now one more time compile and then run it</p>



<p class="wp-block-paragraph">what&#8217;s happening in here</p>



<p class="wp-block-paragraph">third i guess i should probably open this up now third asm so global third and then third oh</p>



<p class="wp-block-paragraph">important part of a system call you got to put the keyword or the instruction system call in there</p>



<p class="wp-block-paragraph">one more time i hope you&#8217;re laughing and cringing at home trying to make this more fun maybe i don&#8217;t</p>



<p class="wp-block-paragraph">know okay so now it&#8217;s all it&#8217;s all working notice how we have a bunch of different modules in</p>



<p class="wp-block-paragraph">different languages we&#8217;re compiling them all to object files first and we&#8217;re uh we&#8217;re linking</p>



<p class="wp-block-paragraph">them all into one executable and we&#8217;re doing this in a really really easy way by using a script</p>



<p class="wp-block-paragraph">script instead of typing all the commands out manually. Pretty convenient, right? Let me give</p>



<p class="wp-block-paragraph">you another upgrade real fast here. So this is kind of irritating. I have like all of these object</p>



<p class="wp-block-paragraph">files that I have to specify. What if I forget to specify some? Since this line 36 is just going to</p>



<p class="wp-block-paragraph">be something that goes directly, you know, to the shell as a command line. This is not like bash</p>



<p class="wp-block-paragraph">wildcards I can say star dot o meaning I&#8217;m going to give every object file to</p>



<p class="wp-block-paragraph">the linker as an input file and that should just work automatically keep in</p>



<p class="wp-block-paragraph">mind if you want to use an advanced strategy like I mentioned earlier where</p>



<p class="wp-block-paragraph">you have multiple different object files and they&#8217;ve each got their own main</p>



<p class="wp-block-paragraph">functions because they&#8217;re each going to be their own separate executables then</p>



<p class="wp-block-paragraph">globbing all object files probably not going to work you might want to organize</p>



<p class="wp-block-paragraph">files or stick the object files for executables in like their own folders or</p>



<p class="wp-block-paragraph">something like that we&#8217;re not going to go that far but I just want you to know</p>



<p class="wp-block-paragraph">so let&#8217;s do that again real fast here we&#8217;ll say clear and compile and I&#8217;ll</p>



<p class="wp-block-paragraph">just try to like run main assuming that the compiler works yes so it worked</p>



<p class="wp-block-paragraph">everything compiled by the way this and end that means only execute the next</p>



<p class="wp-block-paragraph">So if I, you know, clear is obviously going to succeed and then compile, it might succeed</p>



<p class="wp-block-paragraph">or not.</p>



<p class="wp-block-paragraph">Then I&#8217;m going to try to run main.</p>



<p class="wp-block-paragraph">Let me actually, let me actually do that real fast.</p>



<p class="wp-block-paragraph">Let me show you what I&#8217;m talking about.</p>



<p class="wp-block-paragraph">I&#8217;m going to remove main.</p>



<p class="wp-block-paragraph">You&#8217;re okay.</p>



<p class="wp-block-paragraph">So then I&#8217;m going to do clear and compile and main.</p>



<p class="wp-block-paragraph">So obviously if everything works, then everything works.</p>



<p class="wp-block-paragraph">But if I do that again, where something is not actually going to compile, like maybe</p>



<p class="wp-block-paragraph">the second the c source program is not going to compile by putting some z&#8217;s in there then the</p>



<p class="wp-block-paragraph">dot main or yeah that part shouldn&#8217;t get executed so it won&#8217;t try to execute our program</p>



<p class="wp-block-paragraph">notice how it just stops so that&#8217;s convenient if i do it again though with a different command</p>



<p class="wp-block-paragraph">if i chain instead of between the commands instead of putting and end to say one must execute before</p>



<p class="wp-block-paragraph">semicolon then they will all execute no matter whether whether they succeeded or not maybe in</p>



<p class="wp-block-paragraph">certain things you&#8217;re doing you actually want that behavior but in this case it&#8217;s going to be bad</p>



<p class="wp-block-paragraph">watch what happens it fails to compile and then at the end it also tries to run a program that</p>



<p class="wp-block-paragraph">doesn&#8217;t exist because it never got linked because the script stopped so i&#8217;m just letting you know</p>



<p class="wp-block-paragraph">you have lots of different options when you&#8217;re writing these scripts we do it again and then let</p>



<p class="wp-block-paragraph">And I think, well, maybe there&#8217;s one other thing I want you to know.</p>



<p class="wp-block-paragraph">Sometimes these lines get really, really long, right?</p>



<p class="wp-block-paragraph">And it&#8217;s messy and irritating.</p>



<p class="wp-block-paragraph">At least for me.</p>



<p class="wp-block-paragraph">Maybe if it goes off the side of the screen for you, it&#8217;s like, oh, that&#8217;s awful.</p>



<p class="wp-block-paragraph">You can actually just separate a command across multiple lines with a backslash.</p>



<p class="wp-block-paragraph">Or sorry, I think that is called a forward slash.</p>



<p class="wp-block-paragraph">It&#8217;s the drive slash.</p>



<p class="wp-block-paragraph">I don&#8217;t remember forward slash backslash.</p>



<p class="wp-block-paragraph">I just say web slash and drive slash.</p>



<p class="wp-block-paragraph">So I&#8217;m going to do G++ and do a little slash.</p>



<p class="wp-block-paragraph">Then I can put the whole rest of the thing on the next line.</p>



<p class="wp-block-paragraph">If I wanted to, I could start separating these out by category.</p>



<p class="wp-block-paragraph">So maybe I&#8217;m like, oh, I don&#8217;t know.</p>



<p class="wp-block-paragraph">Maybe M64 on its own line.</p>



<p class="wp-block-paragraph">And then I&#8217;ll keep these other two on their own line.</p>



<p class="wp-block-paragraph">And maybe these two on their own line.</p>



<p class="wp-block-paragraph">You know, it&#8217;s up to you how you organize this.</p>



<p class="wp-block-paragraph">And then I&#8217;ll say, give me all the input files on its own line.</p>



<p class="wp-block-paragraph">And then the output file on another line.</p>



<p class="wp-block-paragraph">on another line you could even put the or bars for the die part on its own line I</p>



<p class="wp-block-paragraph">guess I&#8217;ll just try that and now let&#8217;s just make sure that this still compiles</p>



<p class="wp-block-paragraph">let me remove star dot o and remove main it&#8217;s not there okay so clear and then</p>



<p class="wp-block-paragraph">list and then two showed up somewhere oh my mistake I probably should have caught</p>



<p class="wp-block-paragraph">some file got saved as a two I should have noticed okay so let&#8217;s do clear and</p>



<p class="wp-block-paragraph">compile and I just run main okay so now everything works notice how even though</p>



<p class="wp-block-paragraph">everything was on a different line it all just seemed to work cool what about</p>



<p class="wp-block-paragraph">something here on line 38 we&#8217;re using the C++23 standard but we&#8217;re also doing</p>



<p class="wp-block-paragraph">that up here and we&#8217;re also using the all warnings flag up here and down here</p>



<p class="wp-block-paragraph">and pedantic also and even the linker like what if I want to put all warnings</p>



<p class="wp-block-paragraph">into the linker we could make variables in bash and by the way this is totally</p>



<p class="wp-block-paragraph">starting to become a job for for mark for make files but for now we&#8217;re just</p>



<p class="wp-block-paragraph">stay in bash so I can make a variable in bash I can say maybe GCC flags name it something and I&#8217;ll</p>



<p class="wp-block-paragraph">just put equals whatever and I&#8217;ll just type the stuff that I know is going to appear in every</p>



<p class="wp-block-paragraph">single invocation of G++ or GCC so I&#8217;m going to go wall because I want to put that everywhere</p>



<p class="wp-block-paragraph">and I&#8217;m going to say C++23 because I&#8217;m going to put that everywhere and probably pedantic I&#8217;m</p>



<p class="wp-block-paragraph">I&#8217;m not going to put the dash C flag everywhere because notice how I&#8217;m only putting that on the compiler commands when I just want to make an object file.</p>



<p class="wp-block-paragraph">But when I&#8217;m linking, there&#8217;s no dash C because that means you got to actually link.</p>



<p class="wp-block-paragraph">So let&#8217;s see.</p>



<p class="wp-block-paragraph">We got G dwarf two, G dwarf two.</p>



<p class="wp-block-paragraph">Maybe I could put G dwarf two there and see if it still works.</p>



<p class="wp-block-paragraph">So I want debugging symbols and I want them to be in dwarf dash two format, which honestly is the default format.</p>



<p class="wp-block-paragraph">which honestly is the default format if you just put dash G.</p>



<p class="wp-block-paragraph">Let&#8217;s see if I can get away with that for now.</p>



<p class="wp-block-paragraph">So I&#8217;m going to go GCC flags.</p>



<p class="wp-block-paragraph">And here I can get rid of C++23 and wall and pedantic.</p>



<p class="wp-block-paragraph">And I&#8217;ll just insert instead GCC flags.</p>



<p class="wp-block-paragraph">And if you want to be extra careful,</p>



<p class="wp-block-paragraph">you can put these little braces around the variable name of that.</p>



<p class="wp-block-paragraph">Probably should be fine.</p>



<p class="wp-block-paragraph">But because I don&#8217;t want to type that again,</p>



<p class="wp-block-paragraph">I&#8217;m just going to copy paste it into the other command.</p>



<p class="wp-block-paragraph">So wall pedantic, just paste that.</p>



<p class="wp-block-paragraph">Just paste that and then I&#8217;m going to leave it alone for Yasm because Yasm is different than GCC.</p>



<p class="wp-block-paragraph">And then here I&#8217;m going to do another line where I just kind of put the flags.</p>



<p class="wp-block-paragraph">That means I can get rid of those two flags.</p>



<p class="wp-block-paragraph">And then wall and pedantic are going to show up.</p>



<p class="wp-block-paragraph">No pi is kind of a linker only thing.</p>



<p class="wp-block-paragraph">So is the no exec stack.</p>



<p class="wp-block-paragraph">I think probably that will be okay.</p>



<p class="wp-block-paragraph">Let&#8217;s see if I got that right or wrong.</p>



<p class="wp-block-paragraph">Oh no.</p>



<p class="wp-block-paragraph">Unrecognized command line option.</p>



<p class="wp-block-paragraph">Wall pedantic GCC.</p>



<p class="wp-block-paragraph">Oh, I guess because I quoted it.</p>



<p class="wp-block-paragraph">I shouldn&#8217;t have done that.</p>



<p class="wp-block-paragraph">Because I quoted it, the command line thought that that was all one argument.</p>



<p class="wp-block-paragraph">I should have remembered.</p>



<p class="wp-block-paragraph">So I&#8217;m going to unquote it right now.</p>



<p class="wp-block-paragraph">This should help the command line understand that all of the things inside of that variable,</p>



<p class="wp-block-paragraph">the GCC flags, are separate arguments instead of just one argument.</p>



<p class="wp-block-paragraph">Let me try one more time.</p>



<p class="wp-block-paragraph">Yay, it seems to work.</p>



<p class="wp-block-paragraph">Okay, we got a warning here.</p>



<p class="wp-block-paragraph">Command line option C++23 is valid for object,</p>



<p class="wp-block-paragraph">but not for C.</p>



<p class="wp-block-paragraph">Okay, so basically I made the mistake</p>



<p class="wp-block-paragraph">of trying to send a C++ object,</p>



<p class="wp-block-paragraph">which is this right here, or sorry,</p>



<p class="wp-block-paragraph">a C++ argument, which is this right here,</p>



<p class="wp-block-paragraph">into a C compiling command.</p>



<p class="wp-block-paragraph">Not great.</p>



<p class="wp-block-paragraph">So what if I did this?</p>



<p class="wp-block-paragraph">I&#8217;ll do C flags, and it will contain only flags for C,</p>



<p class="wp-block-paragraph">for C and then I&#8217;ll have another one for C++ flags</p>



<p class="wp-block-paragraph">which will only contain things that are for C++ compiling so the regular C compiling can take</p>



<p class="wp-block-paragraph">wall and pedantic okay and then it can take the G dwarf 2 okay the C++ flags it can take everything</p>



<p class="wp-block-paragraph">except for um sorry the C++ flags can actually take all of the C flags and then additionally the</p>



<p class="wp-block-paragraph">and then additionally the the c++ 23 flag so i could embed a variable inside of itself i could</p>



<p class="wp-block-paragraph">say c flags or sorry i could embed a variable inside of another variable so that i can just</p>



<p class="wp-block-paragraph">steal all of the flags from the c flags variable stick them also in the c++ flags variable and</p>



<p class="wp-block-paragraph">then just add one more at the end of that hopefully that works i think it probably will</p>



<p class="wp-block-paragraph">here and then use the C flags here just for compiling I could probably name the</p>



<p class="wp-block-paragraph">variable better put the word compile in there or something but I don&#8217;t really</p>



<p class="wp-block-paragraph">want to I think some people put CC to mean like C compiling but I don&#8217;t know I</p>



<p class="wp-block-paragraph">just want to do it this way so we have that and then we&#8217;re gonna do CPP flags</p>



<p class="wp-block-paragraph">like this we could also organize the variables differently so that the we</p>



<p class="wp-block-paragraph">We could have some linker flags, which basically would probably have all of this stuff minus dash C.</p>



<p class="wp-block-paragraph">And then we could have linking flags.</p>



<p class="wp-block-paragraph">No, we can have linking flags that has all that stuff minus the C.</p>



<p class="wp-block-paragraph">And then we&#8217;ll have like some compiler flags that has the linking flags plus the dash C.</p>



<p class="wp-block-paragraph">But I don&#8217;t really want to spend a bunch of time on this now.</p>



<p class="wp-block-paragraph">For now, we&#8217;ll just say we have C flags and CPP flags.</p>



<p class="wp-block-paragraph">And we&#8217;ll just manually add that dash C.</p>



<p class="wp-block-paragraph">But of course, keep in mind, you can organize these things any way you want.</p>



<p class="wp-block-paragraph">and organize these things any way you want.</p>



<p class="wp-block-paragraph">So I&#8217;m gonna do,</p>



<p class="wp-block-paragraph">well, this might actually work.</p>



<p class="wp-block-paragraph">I&#8217;m getting distracted.</p>



<p class="wp-block-paragraph">I think it works.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">Let me just double check by removing all the object files.</p>



<p class="wp-block-paragraph">There&#8217;s a two in there still.</p>



<p class="wp-block-paragraph">Let&#8217;s debug that if it happens again,</p>



<p class="wp-block-paragraph">then I&#8217;m gonna remove main.</p>



<p class="wp-block-paragraph">Okay, then I&#8217;m just gonna list everything real fast.</p>



<p class="wp-block-paragraph">Okay, let&#8217;s see.</p>



<p class="wp-block-paragraph">Is there gonna be a two in there now?</p>



<p class="wp-block-paragraph">Is there going to be a two in there now?</p>



<p class="wp-block-paragraph">No, is that only when it fails?</p>



<p class="wp-block-paragraph">Only when something fails to compile?</p>



<p class="wp-block-paragraph">I mean, it&#8217;s working, so that&#8217;s good news.</p>



<p class="wp-block-paragraph">You know what?</p>



<p class="wp-block-paragraph">Leave a comment somewhere letting me know</p>



<p class="wp-block-paragraph">where you think I went wrong with this two,</p>



<p class="wp-block-paragraph">and maybe I&#8217;ll release another video</p>



<p class="wp-block-paragraph">or something in the future,</p>



<p class="wp-block-paragraph">at some distant point in the future.</p>



<p class="wp-block-paragraph">But yeah, anyway, I hope you learned a lot of stuff</p>



<p class="wp-block-paragraph">in this video and you had a little bit of fun too.</p>



<p class="wp-block-paragraph">had a little bit of fun too. This has been, you know, a little intro for compiling, linking</p>



<p class="wp-block-paragraph">and executing in Linux, but also probably on a bunch of other systems if you have these</p>



<p class="wp-block-paragraph">same tools, and you&#8217;re working inside of bash. Thank you so much for watching this video.</p>



<p class="wp-block-paragraph">I&#8217;ll see you in the next one.</p>



<p class="wp-block-paragraph">of my heart i really appreciate it i do hope you did learn something and have some fun if you could</p>



<p class="wp-block-paragraph">do me a please a small little favor could you please subscribe and follow this channel or these</p>



<p class="wp-block-paragraph">videos or whatever it is you do on the current social media website that you&#8217;re looking at right</p>



<p class="wp-block-paragraph">now it would really mean the world to me and it&#8217;ll help make more videos and grow this community so</p>



<p class="wp-block-paragraph">we&#8217;ll be able to do more videos longer videos better videos or just i&#8217;ll be able to keep making</p>



<p class="wp-block-paragraph">Do me a kindness and and subscribe. You know sometimes I&#8217;m sleeping in the middle of the night</p>



<p class="wp-block-paragraph">And I just wake up because I know somebody subscribed or followed it just wakes me up and I get filled with joy</p>



<p class="wp-block-paragraph">That&#8217;s exactly what happens every single time</p>



<p class="wp-block-paragraph">So you could do it as a nice favor to me or you could you could troll me if you want to just wake me up in the middle</p>



<p class="wp-block-paragraph">And I just subscribe and then I&#8217;ll just wake up. I promise that&#8217;s what will happen</p>



<p class="wp-block-paragraph">Also, uh, if you look at the middle of the screen right now</p>



<p class="wp-block-paragraph">You should see a QR code which you can scan in order to go to the website</p>



<p class="wp-block-paragraph">go to the website which i think is also named somewhere at the bottom of this video and it&#8217;ll</p>



<p class="wp-block-paragraph">take you to my main website where you can just kind of like see all the videos i published and</p>



<p class="wp-block-paragraph">the services and tutorials and things that i offer and all that good stuff and uh</p>



<p class="wp-block-paragraph">if you have a suggestion for uh uh clarifications or errata or just future videos that you want to</p>



<p class="wp-block-paragraph">see please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on you know just</p>



<p class="wp-block-paragraph">wake up for those in the middle of the night i get i wake up in a cold sweat and i&#8217;m like</p>



<p class="wp-block-paragraph">it would really it really mean the world to me i would really appreciate it so again thank you so</p>



<p class="wp-block-paragraph">much for watching this video and um enjoy the cool music as as i fade into the darkness which is</p>



<p class="wp-block-paragraph">coming for us all</p>



<p class="wp-block-paragraph">Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/compile-link-execute-a-beginners-guide-to-linux-programming-with-c-c-and-assembly/">Compile, Link, Execute: A Beginner’s Guide to Linux Programming with C++, C, and Assembly</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/compile-link-execute-a-beginners-guide-to-linux-programming-with-c-c-and-assembly/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Master GNU Makefiles: Streamline Coding Builds with C++, C &#038; Assembly</title>
		<link>https://www.NeuralLantern.com/master-gnu-makefiles-streamline-coding-builds-with-c-c-assembly/</link>
					<comments>https://www.NeuralLantern.com/master-gnu-makefiles-streamline-coding-builds-with-c-c-assembly/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 25 May 2025 07:53:49 +0000</pubDate>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[assembly programming]]></category>
		<category><![CDATA[beginner coding]]></category>
		<category><![CDATA[build automation]]></category>
		<category><![CDATA[build system]]></category>
		<category><![CDATA[C programming]]></category>
		<category><![CDATA[C++ programming]]></category>
		<category><![CDATA[coding tutorial]]></category>
		<category><![CDATA[coding workflow]]></category>
		<category><![CDATA[compile code]]></category>
		<category><![CDATA[GNU Make]]></category>
		<category><![CDATA[Makefile tutorial]]></category>
		<category><![CDATA[programming tips]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[software engineering]]></category>
		<category><![CDATA[streamline coding]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=113</guid>

					<description><![CDATA[<p>Master GNU Make! Simplify coding with Makefiles, manage C++, C, assembly builds, and cut compile times. Beginner-friendly guide!</p>
<p>The post <a href="https://www.NeuralLantern.com/master-gnu-makefiles-streamline-coding-builds-with-c-c-assembly/">Master GNU Makefiles: Streamline Coding Builds with C++, C &amp; Assembly</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Master GNU Makefiles: Streamline Coding Builds with C++, C &amp; Assembly" width="1380" height="776" src="https://www.youtube.com/embed/fvaoc5Ogp7Y?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Tired of typing endless compile commands? Join me in this fun, hands-on guide to mastering GNU Make! We’ll walk through creating a Makefile to simplify your coding builds, covering C++, C, and assembly projects. Learn how to set up variables, define functions, manage dependencies, and organize build directories to cut compile times drastically. From practical tips like using clean targets to advanced tricks like dynamic variable assignments, this video has it all. Whether you’re a beginner or a seasoned coder, you’ll see how Makefiles can transform your workflow. Plus, I share a real story of turning a 1-hour build into 1 minute! Subscribe for more coding tutorials, and let me know how Makefiles change your game. Scan the QR code for more resources!</p>



<p class="wp-block-paragraph">Introduction to Make Files 00:00:00<br>What is a Build System 00:00:11<br>Problems with Manual Compilation 00:00:16<br>Using Scripts vs Build Systems 00:00:36<br>Benefits of Make Build System 00:00:56<br>Personal Experience with Build Times 00:01:15<br>Creating Sample Source Files 00:02:20<br>Installing Make Build System 00:04:56<br>Creating a Makefile 00:06:02<br>Defining Functions in Makefile 00:06:46<br>Calling Functions and Variables 00:07:13<br>Setting Up Compiler Variables 00:10:51<br>Dynamic vs Static Variable Assignment 00:11:56<br>Compiler and Linker Flags 00:12:44<br>Setting Up Build Paths 00:19:16<br>Printing Variables for Debugging 00:21:24<br>Understanding Targets in Make 00:25:10<br>Dependency Graph and Compilation 01:02:04<br>Managing Build Directory 01:03:11<br>Creating Binary Target 01:05:44<br>Handling Object Files 01:11:29<br>Running the Program 01:13:16<br>Clean Target for Cleanup 01:17:00<br>Advanced Build System Features 01:22:46<br>Git Ignore for Build Files 01:24:34<br>Conclusion and Call to Action 01:25:08</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p class="wp-block-paragraph">Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hey there, let&#8217;s talk about using make files and the make build system.</p>



<p class="wp-block-paragraph">So what&#8217;s a build system? It&#8217;s basically just a program that helps you compile your program.</p>



<p class="wp-block-paragraph">In a previous video, I talked about the idea that it&#8217;s really cumbersome</p>



<p class="wp-block-paragraph">to type out build commands, you know, compiling commands, linking commands and so forth for your</p>



<p class="wp-block-paragraph">cumbersome and you&#8217;ll forget everything that you&#8217;re supposed to be doing. So the next upgrade</p>



<p class="wp-block-paragraph">from that was in a previous video I talked about let&#8217;s take all the commands and put them into a</p>



<p class="wp-block-paragraph">script so that we don&#8217;t really have to remember all the commands. We can just, you know, create</p>



<p class="wp-block-paragraph">a build script and then just kind of run it when we want a program to compile and link and execute.</p>



<p class="wp-block-paragraph">But then the thing is about a script is if you have a very, very large program,</p>



<p class="wp-block-paragraph">it might take a very long time to compile. So a build system will take care of that for you.</p>



<p class="wp-block-paragraph">care of that for you the build system that i&#8217;m about to show you the make build system</p>



<p class="wp-block-paragraph">it can carefully calculate which source code files you&#8217;ve actually changed since the last</p>



<p class="wp-block-paragraph">time that you built your program and it will only rebuild the source code files</p>



<p class="wp-block-paragraph">that actually need to be rebuilt you know into their corresponding object files and such</p>



<p class="wp-block-paragraph">so for as a personal example long time ago before i learned how to use build systems i had a giant</p>



<p class="wp-block-paragraph">And every single little change that I made, I would just have to wait for like an hour.</p>



<p class="wp-block-paragraph">Like I&#8217;d have to go get a sandwich or go do something else or work on a different project for an hour.</p>



<p class="wp-block-paragraph">Then come back and see if my changes actually affected anything.</p>



<p class="wp-block-paragraph">Somewhat quickly, I got irritated enough that I looked into build systems.</p>



<p class="wp-block-paragraph">And I realized that make, the one that I&#8217;m showing you today, is pretty easy.</p>



<p class="wp-block-paragraph">It goes really, really far, but it&#8217;s pretty easy to get started.</p>



<p class="wp-block-paragraph">And it drastically reduced my compile times.</p>



<p class="wp-block-paragraph">set up, you know, the make file and everything so that I let the build system do the building.</p>



<p class="wp-block-paragraph">My build only took like a minute. So I could do like a quick change and then just wait one minute</p>



<p class="wp-block-paragraph">to see the results and then another quick change and so forth. Okay. So if you look at the screen</p>



<p class="wp-block-paragraph">here, I&#8217;m sitting here on a blank desktop. Hopefully I&#8217;m recording everything. Am I?</p>



<p class="wp-block-paragraph">I&#8217;m sitting on a blank page here. So let me just make a couple of source code files. This is not</p>



<p class="wp-block-paragraph">This is not a tutorial for C++ or assembly or anything.</p>



<p class="wp-block-paragraph">I&#8217;m just going to copy paste a couple of sample programs in here real fast.</p>



<p class="wp-block-paragraph">So I&#8217;m creating a C++ source code file.</p>



<p class="wp-block-paragraph">I&#8217;m calling it first.cpp and it&#8217;s going to call functions from other source code files.</p>



<p class="wp-block-paragraph">This is going to be a hybrid program.</p>



<p class="wp-block-paragraph">Again, don&#8217;t really worry about this.</p>



<p class="wp-block-paragraph">My other videos already explained hybrid programs and so forth.</p>



<p class="wp-block-paragraph">I&#8217;m just going to show you how to use the make build system.</p>



<p class="wp-block-paragraph">the make build system.</p>



<p class="wp-block-paragraph">So let&#8217;s make another source code file called second dot C.</p>



<p class="wp-block-paragraph">And then another one called third dot ASM.</p>



<p class="wp-block-paragraph">So I&#8217;m linking a I&#8217;m linking three source.</p>



<p class="wp-block-paragraph">Whoops, that&#8217;s wrong.</p>



<p class="wp-block-paragraph">I&#8217;m linking three source code files.</p>



<p class="wp-block-paragraph">And they&#8217;re all in different languages just to prove to you that this will work</p>



<p class="wp-block-paragraph">with a hybrid program.</p>



<p class="wp-block-paragraph">And so you can kind of see I&#8217;ve got first, second and third.</p>



<p class="wp-block-paragraph">The first one is C++.</p>



<p class="wp-block-paragraph">The second one is just C.</p>



<p class="wp-block-paragraph">Third one is assembly.</p>



<p class="wp-block-paragraph">If I look at it real fast, get ready to pause the video.</p>



<p class="wp-block-paragraph">real fast get ready to pause the video then you can see that it&#8217;s C++ and if we look at the second</p>



<p class="wp-block-paragraph">one it&#8217;s just C and if we look at the third one it&#8217;s just a very simple assembly program and they</p>



<p class="wp-block-paragraph">just sort of say hello and that&#8217;s it okay so you know at this point in my other video I would have</p>



<p class="wp-block-paragraph">made a compile script I&#8217;d say nano compile and then I&#8217;d stick a bunch of compile commands inside</p>



<p class="wp-block-paragraph">of it let&#8217;s see do I even have that from last time let me see if I got it if I have it I&#8217;ll</p>



<p class="wp-block-paragraph">I got it if I have it I&#8217;ll just paste it real fast just to show you compile I don&#8217;t think I&#8217;ve</p>



<p class="wp-block-paragraph">got it although I do okay I&#8217;m just gonna paste it in here and it&#8217;s not the point of this video check</p>



<p class="wp-block-paragraph">my other video if you want to kind of understand everything that&#8217;s going on in here but it&#8217;s just</p>



<p class="wp-block-paragraph">a script so I&#8217;m gonna go compile clear and then list and then in the last video I just said let&#8217;s</p>



<p class="wp-block-paragraph">and it compiles everything and it links the binary and then I can run main which is my binary and then</p>



<p class="wp-block-paragraph">it just runs this program so it&#8217;s no problem it seems okay but again imagine that your program is</p>



<p class="wp-block-paragraph">huge many many lines of source code in every single file and many many many source code files</p>



<p class="wp-block-paragraph">and perhaps you&#8217;re pulling in libraries and shared objects and just like you know a bunch of other</p>



<p class="wp-block-paragraph">stuff your your your building could slow down drastically so I&#8217;m going to remove the compiler</p>



<p class="wp-block-paragraph">the compiler script and then I&#8217;m going to manually remove all the compiled</p>



<p class="wp-block-paragraph">object files. Got to be careful with this. Remove the binary. Okay. So now I&#8217;ve got</p>



<p class="wp-block-paragraph">that one, two, three. Okay. Now I&#8217;m ready to set up a make file. So I guess first</p>



<p class="wp-block-paragraph">you probably should have the make build system installed. If you&#8217;re if you&#8217;re</p>



<p class="wp-block-paragraph">learning about C++ and assembly you probably already do but just just so you</p>



<p class="wp-block-paragraph">know it&#8217;s a it&#8217;s gonna show up in Ubuntu as the build essentials package so</p>



<p class="wp-block-paragraph">So sudo apt install build essentials.</p>



<p class="wp-block-paragraph">I can&#8217;t remember if this is plural or not.</p>



<p class="wp-block-paragraph">It&#8217;s either build essentials or build essential.</p>



<p class="wp-block-paragraph">You can do an apt search or a DNF search depending on your system.</p>



<p class="wp-block-paragraph">We can do build essential and see what shows up.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to go to the top build essential.</p>



<p class="wp-block-paragraph">Okay, so it was singular, not plural.</p>



<p class="wp-block-paragraph">I have it installed already.</p>



<p class="wp-block-paragraph">Let&#8217;s see.</p>



<p class="wp-block-paragraph">If you just want to install make by itself, you can probably do apt search.</p>



<p class="wp-block-paragraph">search, just make and go up to the Ms.</p>



<p class="wp-block-paragraph">You can see right here.</p>



<p class="wp-block-paragraph">It&#8217;s just pseudo apt install.</p>



<p class="wp-block-paragraph">Make is all you really have to do to get the whole make build system.</p>



<p class="wp-block-paragraph">They&#8217;ve got a website, you know, search for Gnu make.</p>



<p class="wp-block-paragraph">I&#8217;m going to type it on the screen here.</p>



<p class="wp-block-paragraph">Gnu make search for that.</p>



<p class="wp-block-paragraph">You&#8217;ll get a nice website with a bunch</p>



<p class="wp-block-paragraph">of documentation and examples that go way beyond this video.</p>



<p class="wp-block-paragraph">But I&#8217;m just going to show you the basics so you can get started.</p>



<p class="wp-block-paragraph">So the first thing you should do is create a file called make file.</p>



<p class="wp-block-paragraph">create a file called make file. I think under lowercase m is supported but I usually do uppercase</p>



<p class="wp-block-paragraph">m which is obviously supported because I always do it and what you&#8217;re really going to do is you&#8217;re</p>



<p class="wp-block-paragraph">just going to create an empty file call it make file and then inside of the make file you&#8217;re just</p>



<p class="wp-block-paragraph">going to give make a bunch of commands and things that you want it to do and then later when you&#8217;re</p>



<p class="wp-block-paragraph">actually ready to compile you&#8217;ll just type make as a command and then give make an instruction and</p>



<p class="wp-block-paragraph">have lots of instructions and targets available inside of the make file for</p>



<p class="wp-block-paragraph">make to grab onto. Okay, so moving on. The first thing I want to show you is how to</p>



<p class="wp-block-paragraph">define a function in make. You probably won&#8217;t do this a lot, but for me I kind of</p>



<p class="wp-block-paragraph">like to print, you know, pretty messages and sort of like do repetitive tasks in a</p>



<p class="wp-block-paragraph">function. So when you want to define a function you just use the keyword define</p>



<p class="wp-block-paragraph">and then you name the function. So I&#8217;m gonna make a function called say which I</p>



<p class="wp-block-paragraph">see what it&#8217;s for I know it&#8217;s silly define say and then I&#8217;m going to tab here and then I&#8217;m going to</p>



<p class="wp-block-paragraph">tell it to print some information I&#8217;ll just put test info for now the thing about calling functions</p>



<p class="wp-block-paragraph">is you usually put a dollar sign and then an open parenthesis and then the name of the function and</p>



<p class="wp-block-paragraph">then after that arguments to the function so here you can see actually let me get line numbers up</p>



<p class="wp-block-paragraph">here on nano you can see online too I am calling a function called info it&#8217;s a built-in system</p>



<p class="wp-block-paragraph">it&#8217;s a built-in system function you don&#8217;t have to define it yourself and I&#8217;m</p>



<p class="wp-block-paragraph">telling it I want you to print some info to the screen and I want you to print</p>



<p class="wp-block-paragraph">test info to the screen and that&#8217;s it so in my make file I can just call that</p>



<p class="wp-block-paragraph">right away with call you know dollar sign parentheses and then the keyword</p>



<p class="wp-block-paragraph">call and then name the function that I want to call closing parentheses and</p>



<p class="wp-block-paragraph">then if the function takes arguments I put a comma and then just start</p>



<p class="wp-block-paragraph">providing the argument so I&#8217;ll just say hello what&#8217;s up actually this shouldn&#8217;t</p>



<p class="wp-block-paragraph">up. Actually, this shouldn&#8217;t take my arguments right now. We&#8217;ll upgrade it in a second. But</p>



<p class="wp-block-paragraph">so this is a very simple makefile. It doesn&#8217;t actually have any targets. It will just simply</p>



<p class="wp-block-paragraph">do things. This kind of stuff is useful. At the very top of your makefile later, we&#8217;re going to</p>



<p class="wp-block-paragraph">define like a bunch of variables. And sometimes it&#8217;s nice to print them out. So I just want to</p>



<p class="wp-block-paragraph">show you how to start printing so that maybe if your makefile isn&#8217;t working, you&#8217;ll realize that,</p>



<p class="wp-block-paragraph">oh, that variable is wrong because you printed everything when it started up. You don&#8217;t have to</p>



<p class="wp-block-paragraph">You don&#8217;t have to do it that way.</p>



<p class="wp-block-paragraph">I just like to.</p>



<p class="wp-block-paragraph">So how do you invoke the make file?</p>



<p class="wp-block-paragraph">We just literally type make.</p>



<p class="wp-block-paragraph">And because we named the make file, make file,</p>



<p class="wp-block-paragraph">the make program will automatically figure out</p>



<p class="wp-block-paragraph">where it is and go find it and load it.</p>



<p class="wp-block-paragraph">But you can specify the name of a make file</p>



<p class="wp-block-paragraph">if you really want to.</p>



<p class="wp-block-paragraph">I think it&#8217;s the dash F switch.</p>



<p class="wp-block-paragraph">Actually, let me look it up just to be sure.</p>



<p class="wp-block-paragraph">I&#8217;m gonna go man make and just go down a second here.</p>



<p class="wp-block-paragraph">Yeah.</p>



<p class="wp-block-paragraph">So this switch right here,</p>



<p class="wp-block-paragraph">here dash f and then specify the file name or file path or dash dash file and then specify the name</p>



<p class="wp-block-paragraph">or path that&#8217;s how you could use a non-standard make file but almost no one does that everyone</p>



<p class="wp-block-paragraph">just likes to to name it this way and then just type make so if i type make notice how the first</p>



<p class="wp-block-paragraph">thing it does is it says test info which is what i told it to do in that function which i called</p>



<p class="wp-block-paragraph">and then it says no targets gotta stop because we didn&#8217;t add any targets yet okay by the way if</p>



<p class="wp-block-paragraph">about what I&#8217;m even doing this for like compiling and whatever go see my other</p>



<p class="wp-block-paragraph">videos where we talk about compiling and linking and all that stuff this is just</p>



<p class="wp-block-paragraph">to make things a lot more easy and powerful so let&#8217;s upgrade this save</p>



<p class="wp-block-paragraph">function and I&#8217;m just gonna put some brackets and I&#8217;m gonna say my super cool</p>



<p class="wp-block-paragraph">make how about like builder I guess and then instead of test info I&#8217;m gonna put</p>



<p class="wp-block-paragraph">dollar sign one which basically is gonna tell this function you know when I call</p>



<p class="wp-block-paragraph">say, then the dollar sign one variable is going to show up as the first argument that I provided.</p>



<p class="wp-block-paragraph">So now when I call say, it should have hello, what&#8217;s up as the first argument that goes into</p>



<p class="wp-block-paragraph">the function. So that means it should print my super cool builder and then the message that I</p>



<p class="wp-block-paragraph">had it print. One more time, notice how it says my super cool builder. Hello, what&#8217;s up, I just like</p>



<p class="wp-block-paragraph">to do it this way, because then it&#8217;s easier for me to differentiate messages that the build system</p>



<p class="wp-block-paragraph">itself from the actual make file and messages that maybe the tools I&#8217;m calling on are giving like GCC or whatever</p>



<p class="wp-block-paragraph">So let&#8217;s edit this a little bit more</p>



<p class="wp-block-paragraph">The second thing I would like to do is well, maybe I&#8217;ll change this to just you know now running or something</p>



<p class="wp-block-paragraph">Now let&#8217;s set up some variables. I&#8217;m gonna do like a little thing here. I&#8217;m gonna say variables</p>



<p class="wp-block-paragraph">Put a bunch of comments in make files comments are just hashes</p>



<p class="wp-block-paragraph">So, you know, this, these lines right here don&#8217;t really do anything, 9, 10, 11.</p>



<p class="wp-block-paragraph">And I&#8217;m going to start setting up some variables for my compilers.</p>



<p class="wp-block-paragraph">So again, actually compiling is in a different video.</p>



<p class="wp-block-paragraph">We assume right now that you already know how to do it.</p>



<p class="wp-block-paragraph">So I&#8217;m going to say, let&#8217;s do some variables for compilers.</p>



<p class="wp-block-paragraph">You don&#8217;t have to do it this way, but the standard convention for naming a regular C</p>



<p class="wp-block-paragraph">compilers or GCC seems to be just CC as the variable name.</p>



<p class="wp-block-paragraph">So I&#8217;m saying a variable named CC is going to be equal to GCC.</p>



<p class="wp-block-paragraph">to be equal to GCC and then from this point forward every time I use the variable CC in my</p>



<p class="wp-block-paragraph">script in my makefile it&#8217;s actually going to be like typing GCC and you know if you don&#8217;t understand</p>



<p class="wp-block-paragraph">why you would use variables you probably need to learn how to code a little bit more but basically</p>



<p class="wp-block-paragraph">it makes everything more powerful instead of typing GCC everywhere and then maybe later if I</p>



<p class="wp-block-paragraph">want to change it I have to go change it in a million places now I can just change it in one</p>



<p class="wp-block-paragraph">place and so it&#8217;s more powerful let&#8217;s do the same thing for the C++ compiler I&#8217;m going to say G++</p>



<p class="wp-block-paragraph">compiler I&#8217;m gonna say G++ same thing for my Yasm assembler I&#8217;m gonna say</p>



<p class="wp-block-paragraph">we&#8217;re using Yasm also notice how when I assign variables I&#8217;m not just using an</p>



<p class="wp-block-paragraph">equality or an assignment operator I&#8217;m not just doing equals that is a little</p>



<p class="wp-block-paragraph">bit different of a way to assign you can do that but if you just put an</p>



<p class="wp-block-paragraph">assignment operator by itself just like the equal then if you later change</p>



<p class="wp-block-paragraph">depends on on the right side, like another variable, then it will update on the left</p>



<p class="wp-block-paragraph">side. So it&#8217;s like, it&#8217;s not really a permanent assignment. It&#8217;s more like a dynamic assignment.</p>



<p class="wp-block-paragraph">So, you know, if you want to make sure that the variable has a fixed value that doesn&#8217;t change,</p>



<p class="wp-block-paragraph">even if you start changing variables that it depends on, then use colon equal. I&#8217;ll just leave it at that for now.</p>



<p class="wp-block-paragraph">Not super important. You can also tab and, you know, kind of line things up and it&#8217;s no problem.</p>



<p class="wp-block-paragraph">just to make things look nicer.</p>



<p class="wp-block-paragraph">So now let&#8217;s set up some flags for C and C++ and YASM.</p>



<p class="wp-block-paragraph">So I&#8217;m going to create a variable called ccflags,</p>



<p class="wp-block-paragraph">do the same thing again where I do the colon assignment operator.</p>



<p class="wp-block-paragraph">I&#8217;m just going to give it some flags.</p>



<p class="wp-block-paragraph">I want it to show me all warnings,</p>



<p class="wp-block-paragraph">and I want it to be pedantic about its warnings,</p>



<p class="wp-block-paragraph">and I want it to generate debug symbols.</p>



<p class="wp-block-paragraph">build system we want to try to compile source code files into object files first</p>



<p class="wp-block-paragraph">and then at a different stage link the object files together we we don&#8217;t want</p>



<p class="wp-block-paragraph">to just compile everything in one fell swoop directly to a binary in one line</p>



<p class="wp-block-paragraph">because we wouldn&#8217;t really be leveraging the power of the build system in a</p>



<p class="wp-block-paragraph">moment I&#8217;m going to draw a diagram that tries to make this a little more clear</p>



<p class="wp-block-paragraph">for now I&#8217;m just typing up variables so just bear with me when I&#8217;m you know</p>



<p class="wp-block-paragraph">Cpp flags.</p>



<p class="wp-block-paragraph">So for C++, I&#8217;m actually going to reuse a variable here.</p>



<p class="wp-block-paragraph">I&#8217;m going to reuse the CC flags because all the flags</p>



<p class="wp-block-paragraph">above are fine for C++ as well as C.</p>



<p class="wp-block-paragraph">So that means like in my C++ compilation,</p>



<p class="wp-block-paragraph">I want all warnings and I want it to be pedantic and I want to generate debug</p>



<p class="wp-block-paragraph">symbols, but in C++, we&#8217;ll specify the C++ standard.</p>



<p class="wp-block-paragraph">So C++ 23.</p>



<p class="wp-block-paragraph">kind of already leveraging variables against other variables to save typing and make things a little</p>



<p class="wp-block-paragraph">bit more module. If I decided that all my C was not going to show warnings or was going to convert</p>



<p class="wp-block-paragraph">all warnings into errors or, you know, use a different flag or something, all I&#8217;d have to do</p>



<p class="wp-block-paragraph">is change it in one spot, line 20 and line 21 would automatically get updated. Also keep in mind</p>



<p class="wp-block-paragraph">because like I said before, we have this colon assignment operator here going on the right side.</p>



<p class="wp-block-paragraph">value of cc flags then it would be reflected if i didn&#8217;t use um the assignment operator you know</p>



<p class="wp-block-paragraph">what let&#8217;s let&#8217;s just do it let&#8217;s just do it real fast i&#8217;m going to say call say i&#8217;m going to say</p>



<p class="wp-block-paragraph">let&#8217;s let&#8217;s see cpp flags is and then i&#8217;m just going to print cpp flags you print variables kind</p>



<p class="wp-block-paragraph">of the same way that you call functions you just put a dollar sign and then surround the variable</p>



<p class="wp-block-paragraph">name in a set of parentheses and that&#8217;s pretty much it so i&#8217;m going to copy this line a couple</p>



<p class="wp-block-paragraph">And in between CPP flags, actually let&#8217;s do CC flags.</p>



<p class="wp-block-paragraph">We&#8217;ll assign CC flags to something.</p>



<p class="wp-block-paragraph">I&#8217;ll say hello test.</p>



<p class="wp-block-paragraph">And right now the way CPP flags is written, the assignment kind of sticks.</p>



<p class="wp-block-paragraph">It&#8217;s like permanent fixed.</p>



<p class="wp-block-paragraph">It doesn&#8217;t dynamically depend on CC flags.</p>



<p class="wp-block-paragraph">So we should see two instances of the exact same message.</p>



<p class="wp-block-paragraph">Let me open up another window here because I want to keep that editor open.</p>



<p class="wp-block-paragraph">because I don&#8217;t I want to keep that editor open so we&#8217;ll do a make and notice how when it prints</p>



<p class="wp-block-paragraph">the CPP flags they&#8217;re the same it&#8217;s the same both times even though I changed CC flags in between</p>



<p class="wp-block-paragraph">those two messages on the other hand if I don&#8217;t put that to colon if I just put a sign then now</p>



<p class="wp-block-paragraph">it is dynamic notice how the second message uses the modified version of cc flags so keep that in</p>



<p class="wp-block-paragraph">So keep that in mind if you want a variable to be able to change anytime you depend on</p>



<p class="wp-block-paragraph">anytime a dependent variable that it depends on changes you&#8217;ll assign one way and if you</p>



<p class="wp-block-paragraph">don&#8217;t want it to change you&#8217;ll assign it another way okay so that&#8217;s enough of that I&#8217;m going to</p>



<p class="wp-block-paragraph">take away that message and I&#8217;m going to change this back to non-dynamic okay then we&#8217;ll do the</p>



<p class="wp-block-paragraph">same thing for assembly assembly flags this is going to be the Yasm compiler I&#8217;m going to tell</p>



<p class="wp-block-paragraph">I&#8217;m going to tell it that I want ELF 64.</p>



<p class="wp-block-paragraph">I want a 64 bit executable.</p>



<p class="wp-block-paragraph">I want to dwarf to debug symbols.</p>



<p class="wp-block-paragraph">I think in Yasm you have to specify the type of symbol.</p>



<p class="wp-block-paragraph">I think I can&#8217;t remember if you actually need to.</p>



<p class="wp-block-paragraph">So you could try just, you know, dash G if you want.</p>



<p class="wp-block-paragraph">It may or may not work.</p>



<p class="wp-block-paragraph">But I always just like to specify at least for assembly.</p>



<p class="wp-block-paragraph">So then let&#8217;s do some linker flags.</p>



<p class="wp-block-paragraph">Okay, so link flags, you know, what is the linking stage?</p>



<p class="wp-block-paragraph">What&#8217;s going to happen in a hybrid program?</p>



<p class="wp-block-paragraph">You know, for me, it&#8217;s just going to be the G plus plus GCC linker.</p>



<p class="wp-block-paragraph">So that means I&#8217;m going to do all the CPP flags because I want wall and pedantic and</p>



<p class="wp-block-paragraph">debug symbols and I want the C plus plus standard set and all that stuff.</p>



<p class="wp-block-paragraph">Whatever you want to do is fine.</p>



<p class="wp-block-paragraph">And then I want to just specify.</p>



<p class="wp-block-paragraph">I don&#8217;t think you have to do this on modern systems, but I&#8217;m going to specify I want to link a 64-bit executable</p>



<p class="wp-block-paragraph">And then I have to specify no pi</p>



<p class="wp-block-paragraph">Which I think is kind of an Ubuntu thing your program probably won&#8217;t run if you don&#8217;t do this</p>



<p class="wp-block-paragraph">So just trust me for now put no pi in the linking stage and then we&#8217;ll do another flag called no exec stack</p>



<p class="wp-block-paragraph">Which is also a somewhat new thing which prevents</p>



<p class="wp-block-paragraph">stack which means you might be less hackable not sure if it&#8217;s how safe it really is but you know</p>



<p class="wp-block-paragraph">probably improves the safety a little bit uh let&#8217;s see at the last minute okay so now uh</p>



<p class="wp-block-paragraph">now that i&#8217;ve set up the link flags uh i need to like add on the dash c flag for the actual</p>



<p class="wp-block-paragraph">compiler flags because uh you know if if you know this from my previous videos if you&#8217;re going to</p>



<p class="wp-block-paragraph">compile to an object file and not directly link everything right away you need to add the dash c</p>



<p class="wp-block-paragraph">away you need to add the dash c flag to let the compiler know oh i just want to compile to an</p>



<p class="wp-block-paragraph">object file and then later i&#8217;ll come along and link so i&#8217;m going to go cpp flags is equal to</p>



<p class="wp-block-paragraph">and i&#8217;m going to say equal to itself and then just add a dash c at the end of it and then we&#8217;ll do</p>



<p class="wp-block-paragraph">cc flags and then it&#8217;s going to equal to itself with just a dash c at the end of it so</p>



<p class="wp-block-paragraph">I had CPP flags on line 21 equal to just this basic thing.</p>



<p class="wp-block-paragraph">And then I reused CPP flags for the link flags,</p>



<p class="wp-block-paragraph">which means if the link flags didn&#8217;t use that colon,</p>



<p class="wp-block-paragraph">I would basically have ruined the link flags variable by the time I went down</p>



<p class="wp-block-paragraph">here and changed it. So you don&#8217;t have to organize your make file this way.</p>



<p class="wp-block-paragraph">You can actually hard code a lot more stuff into the variables.</p>



<p class="wp-block-paragraph">I just like to try to be more dynamic. It&#8217;s more fun.</p>



<p class="wp-block-paragraph">up all the basic variables for the compiler let&#8217;s set up some variables for paths so i&#8217;m</p>



<p class="wp-block-paragraph">going to set up paths here so what do i mean by paths you know this is a build system it&#8217;s got to</p>



<p class="wp-block-paragraph">know where things are right so for starters you probably want to name your binary you know the</p>



<p class="wp-block-paragraph">executable file so i&#8217;m just going to make mine main you can make anything you want like my program or</p>



<p class="wp-block-paragraph">whatever but you know for mine it&#8217;s going to be main and then i&#8217;m going to set up another variable</p>



<p class="wp-block-paragraph">going to set up another variable that depends on it so I&#8217;m going to say the actual binary path is</p>



<p class="wp-block-paragraph">just going to be you know this main meaning the current directory and main also you know most it</p>



<p class="wp-block-paragraph">seems like most make files have it set up so that all of the intermediate files like the the object</p>



<p class="wp-block-paragraph">files and the binary they get built in the current source directory you know like the root of the</p>



<p class="wp-block-paragraph">Sometimes also I like to just make a build directory.</p>



<p class="wp-block-paragraph">So it&#8217;s really, really easy to just kind of clean everything out.</p>



<p class="wp-block-paragraph">You just delete the build directory and you don&#8217;t have to worry about the repository getting</p>



<p class="wp-block-paragraph">super cluttered with object files in the meantime.</p>



<p class="wp-block-paragraph">So I&#8217;m going to name a build directory here.</p>



<p class="wp-block-paragraph">I&#8217;m going to say build directory name is build.</p>



<p class="wp-block-paragraph">And then so you can imagine there&#8217;s going to be a folder here now named build that shows</p>



<p class="wp-block-paragraph">up whenever, well, I&#8217;m going to add more targets later when I actually start building.</p>



<p class="wp-block-paragraph">when I actually start building, we&#8217;re still just naming things.</p>



<p class="wp-block-paragraph">So then I&#8217;m going to name the actual build directory as the current directory slash and then build dir name.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So that means the bin shouldn&#8217;t just be in the current directory.</p>



<p class="wp-block-paragraph">It should be in the build dir and then a slash.</p>



<p class="wp-block-paragraph">And then instead of typing main, actually, I should probably reuse that variable.</p>



<p class="wp-block-paragraph">So let&#8217;s do bin name.</p>



<p class="wp-block-paragraph">And again, reusing variables is really, really good because it just saves you work.</p>



<p class="wp-block-paragraph">I can change things in less places when I leverage variables more.</p>



<p class="wp-block-paragraph">If I had the word main written down all over the program, I&#8217;d have to change that in every</p>



<p class="wp-block-paragraph">single spot of the make file if I wanted to change main to something else.</p>



<p class="wp-block-paragraph">But in this case, I only have to change it in one spot.</p>



<p class="wp-block-paragraph">Okay, so now maybe it&#8217;s probably a good idea at this point to start printing out what we&#8217;ve</p>



<p class="wp-block-paragraph">done.</p>



<p class="wp-block-paragraph">So I&#8217;m going to do a bunch of, you know, calls to print things.</p>



<p class="wp-block-paragraph">you know calls to print things print everything out just for double checking ourselves</p>



<p class="wp-block-paragraph">okay how can i do that i&#8217;m going to do that with a call uh the uh say you could also just do uh info</p>



<p class="wp-block-paragraph">and then you know something like that like we did up above in the save function if you want a less</p>



<p class="wp-block-paragraph">fancier build system but i like doing it this way so i&#8217;m going to say what um let&#8217;s do cc uh</p>



<p class="wp-block-paragraph">CC and I&#8217;ll just put maybe like a quality operator or something and then</p>



<p class="wp-block-paragraph">I&#8217;ll just print out what I put for CC and I&#8217;ll just start duplicating this</p>



<p class="wp-block-paragraph">line a few times and I&#8217;ll say I&#8217;ll just print out everything that I added as a</p>



<p class="wp-block-paragraph">variable CPP and then ASM type ASM and this just kind of you know it just kind</p>



<p class="wp-block-paragraph">typed something in incorrectly might take me a while to figure that out but if</p>



<p class="wp-block-paragraph">I print it all out at the beginning of the of the make file running that I can</p>



<p class="wp-block-paragraph">just visually inspect what the variables actually contain so let&#8217;s do CPP flags</p>



<p class="wp-block-paragraph">and then we&#8217;ll do CC flags</p>



<p class="wp-block-paragraph">SM flags.</p>



<p class="wp-block-paragraph">And then we&#8217;ll do one more.</p>



<p class="wp-block-paragraph">It&#8217;s going to be probably, oh, link flags.</p>



<p class="wp-block-paragraph">There we go.</p>



<p class="wp-block-paragraph">So link flags.</p>



<p class="wp-block-paragraph">Bringing out a lot of stuff here.</p>



<p class="wp-block-paragraph">Then I can print the directories, I guess.</p>



<p class="wp-block-paragraph">So maybe I&#8217;ll duplicate this a few more times.</p>



<p class="wp-block-paragraph">I want to do builder.</p>



<p class="wp-block-paragraph">The build directory, just so I know where it is.</p>



<p class="wp-block-paragraph">and I can verify that it&#8217;s like a real path.</p>



<p class="wp-block-paragraph">Builder, maybe I&#8217;ll duplicate this one more time</p>



<p class="wp-block-paragraph">so that I can see the absolute path</p>



<p class="wp-block-paragraph">to the build directory.</p>



<p class="wp-block-paragraph">Just for my own information,</p>



<p class="wp-block-paragraph">because sometimes if you get it wrong,</p>



<p class="wp-block-paragraph">this is another way to kind of see what&#8217;s going on.</p>



<p class="wp-block-paragraph">So there&#8217;s a function in make that&#8217;s built in.</p>



<p class="wp-block-paragraph">You pretty much just say dollar</p>



<p class="wp-block-paragraph">and the name of the function is abspath.</p>



<p class="wp-block-paragraph">path and whatever you put inside of it it&#8217;ll try to give you the absolute path of that thing</p>



<p class="wp-block-paragraph">so i&#8217;m just telling it now that i want to print the absolute path of the build directory</p>



<p class="wp-block-paragraph">by the way um you probably don&#8217;t want to convert all of your variables to absolute paths because</p>



<p class="wp-block-paragraph">make has a huge problem with spaces in paths and file names so keep it relative unless you&#8217;re just</p>



<p class="wp-block-paragraph">going to print something um you&#8217;ll find out the hard way i mean feel free to try it and prove to</p>



<p class="wp-block-paragraph">yourself it&#8217;s not a good idea um but i found it the hard way many times because i kept forgetting</p>



<p class="wp-block-paragraph">I kept forgetting. So then we&#8217;ll just do the binary, I guess. Okay. Yeah. We&#8217;ll do one more</p>



<p class="wp-block-paragraph">for the binary. It&#8217;s going to go there and maybe I&#8217;ll duplicate this so that I can say</p>



<p class="wp-block-paragraph">what the absolute path is. Okay. Abs path. And then if I screw this up, I&#8217;ll just look up the</p>



<p class="wp-block-paragraph">I&#8217;m going to do clear and make so I can just see what it&#8217;s going to print.</p>



<p class="wp-block-paragraph">And let me just double check here.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So everything looks good there.</p>



<p class="wp-block-paragraph">Looks good there.</p>



<p class="wp-block-paragraph">Looks pretty good.</p>



<p class="wp-block-paragraph">Absolute path to the builder is my stuff.</p>



<p class="wp-block-paragraph">All right.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So seems good so far.</p>



<p class="wp-block-paragraph">I&#8217;m just going to leave that in there because it&#8217;ll be easy to double check it.</p>



<p class="wp-block-paragraph">And now we&#8217;re going to do targets.</p>



<p class="wp-block-paragraph">So what is the target in the make build system?</p>



<p class="wp-block-paragraph">in the make build system a target is just something that you might want to create or or</p>



<p class="wp-block-paragraph">or build or compile or something targets are not only for uh building uh executables or object</p>



<p class="wp-block-paragraph">files or you know something that you make targets sometimes can just be called they&#8217;re called phony</p>



<p class="wp-block-paragraph">targets but you can just call a target and it will execute a bunch of commands within that target</p>



<p class="wp-block-paragraph">even though it&#8217;s not building something specific that is needed so you can use make files to do a</p>



<p class="wp-block-paragraph">really powerful stuff. Let me show you first off, we&#8217;ll do a we&#8217;ll do a target. I&#8217;ve already</p>



<p class="wp-block-paragraph">prepared something up here. I&#8217;m just gonna I&#8217;m just gonna copy paste it here because it&#8217;s going</p>



<p class="wp-block-paragraph">to take a long time to type if I don&#8217;t. So here&#8217;s a target. An example of a target is okay, I&#8217;m going</p>



<p class="wp-block-paragraph">to name the target the target menu and I&#8217;m gonna put a colon. So now later I can type make menu</p>



<p class="wp-block-paragraph">and what will happen is it&#8217;ll execute all those commands that are listed below. Each command</p>



<p class="wp-block-paragraph">is really just going to be a shell command.</p>



<p class="wp-block-paragraph">You have to use tab to indent for the command itself.</p>



<p class="wp-block-paragraph">Notice how I have a bunch of echo statements</p>



<p class="wp-block-paragraph">and then I&#8217;m just like printing stuff, right?</p>



<p class="wp-block-paragraph">So this whole target, it doesn&#8217;t actually build anything,</p>



<p class="wp-block-paragraph">but it will print a menu to the screen for me,</p>



<p class="wp-block-paragraph">which is pretty convenient.</p>



<p class="wp-block-paragraph">When you&#8217;re not actually building something,</p>



<p class="wp-block-paragraph">like you&#8217;re not building the executable</p>



<p class="wp-block-paragraph">that the target doesn&#8217;t name an executable,</p>



<p class="wp-block-paragraph">then it&#8217;s called a phony target.</p>



<p class="wp-block-paragraph">And you want to name it as a phony target</p>



<p class="wp-block-paragraph">phony target with this line 67 down here because if you don&#8217;t the build system might actually</p>



<p class="wp-block-paragraph">eventually end up getting confused between a fake target and something that might be sitting on your</p>



<p class="wp-block-paragraph">file system like if i accidentally put a file named menu on my file system at the root of my</p>



<p class="wp-block-paragraph">repository then make might get confused and think well i see the file so therefore i don&#8217;t need to</p>



<p class="wp-block-paragraph">build it and then the menu will never show up again so this way i&#8217;m saying this is a phony target</p>



<p class="wp-block-paragraph">at the file system it&#8217;ll just always execute that target for me so this is the basics of a target</p>



<p class="wp-block-paragraph">you just name a target put a colon and then every line under that is a shell command that you wanted</p>



<p class="wp-block-paragraph">to execute so let me just show you that real fast we save to be sure so we&#8217;re going to do clear and</p>



<p class="wp-block-paragraph">actually the absolute paths are starting to bother me let me get rid of them right now</p>



<p class="wp-block-paragraph">head before I made this video. Okay, and we can just sort of trim the fat a little bit. So I&#8217;m</p>



<p class="wp-block-paragraph">going to do clear and make. And notice how the menu target just ran by itself already.</p>



<p class="wp-block-paragraph">The convenient thing about make files is the first target that shows up is going to be known</p>



<p class="wp-block-paragraph">as the default target and it will just get executed automatically if you don&#8217;t specify</p>



<p class="wp-block-paragraph">what to execute. So notice how I just typed make by itself and I didn&#8217;t actually specify a target.</p>



<p class="wp-block-paragraph">I could specify make menu and the same exact thing happens.</p>



<p class="wp-block-paragraph">Notice how I said make menu, the menu shows up again.</p>



<p class="wp-block-paragraph">But if you don&#8217;t specify anything,</p>



<p class="wp-block-paragraph">then it&#8217;ll always execute the first found target.</p>



<p class="wp-block-paragraph">And just to prove that to you right here,</p>



<p class="wp-block-paragraph">I&#8217;ll do maybe I&#8217;ll do like a different target</p>



<p class="wp-block-paragraph">and I&#8217;ll just call it hello.</p>



<p class="wp-block-paragraph">And I&#8217;ll just have it echo hello.</p>



<p class="wp-block-paragraph">So now if we just execute make with no arguments,</p>



<p class="wp-block-paragraph">notice how it just prints hello.</p>



<p class="wp-block-paragraph">if I want the menu again, I got to go make menu.</p>



<p class="wp-block-paragraph">Right? Okay. So I&#8217;m going to, I&#8217;m going to set the menu back to the default target.</p>



<p class="wp-block-paragraph">Another thing that sometimes people do is they&#8217;ll just make a target called default.</p>



<p class="wp-block-paragraph">I guess I&#8217;ll do that here, make a target called default. And they&#8217;ll say that the</p>



<p class="wp-block-paragraph">default target depends on whatever they want to actually run. And you don&#8217;t even need to</p>



<p class="wp-block-paragraph">call it default. You can call it hello or anything that you want. So, you know,</p>



<p class="wp-block-paragraph">put to lead default just so you know that this is not a standard system name that&#8217;s expected so</p>



<p class="wp-block-paragraph">the default target it&#8217;s just the name of the target then a colon and instead of putting shell</p>



<p class="wp-block-paragraph">commands underneath i could put dependencies on the right so now i&#8217;m saying that the default target</p>



<p class="wp-block-paragraph">depends on the menu target which means in the make build system first what it&#8217;s going to do is it&#8217;s</p>



<p class="wp-block-paragraph">going to go check to make sure that main or sorry menu is satisfied because menu is actually a fake</p>



<p class="wp-block-paragraph">Because menu is actually a fake, you know, a phony target, it&#8217;s always going to get executed.</p>



<p class="wp-block-paragraph">And then when it&#8217;s finished and laDefault realizes, okay, all of my dependencies are satisfied now,</p>



<p class="wp-block-paragraph">then laDefault is going to execute and it&#8217;s actually going to end up doing nothing.</p>



<p class="wp-block-paragraph">I mean, we could put some commands under here if we want.</p>



<p class="wp-block-paragraph">I&#8217;ll put the word nothing.</p>



<p class="wp-block-paragraph">And just to prove to you that menu will get executed first because it&#8217;s a dependency of laDefault.</p>



<p class="wp-block-paragraph">And then finally laDefault will execute its commands and print the word nothing.</p>



<p class="wp-block-paragraph">execute its commands and print the word nothing.</p>



<p class="wp-block-paragraph">Let&#8217;s do that and then I&#8217;ll erase the echo command there.</p>



<p class="wp-block-paragraph">So we&#8217;ll do clear and make.</p>



<p class="wp-block-paragraph">Notice how the menu got printed first</p>



<p class="wp-block-paragraph">because it was a dependency of the default</p>



<p class="wp-block-paragraph">and the default is the default target.</p>



<p class="wp-block-paragraph">And then after the dependencies were satisfied,</p>



<p class="wp-block-paragraph">then the default did its thing and printed nothing.</p>



<p class="wp-block-paragraph">But so let&#8217;s get rid of that.</p>



<p class="wp-block-paragraph">And now it&#8217;s just like when you do make with no arguments,</p>



<p class="wp-block-paragraph">then the menu gets printed.</p>



<p class="wp-block-paragraph">printed. Okay, so what else can I talk about real fast here? Let&#8217;s talk about</p>



<p class="wp-block-paragraph">silent commands. I&#8217;ll put a little comment menu. Let&#8217;s talk about silent</p>



<p class="wp-block-paragraph">commands. You see all these at symbols here? There are a bunch of symbols that</p>



<p class="wp-block-paragraph">you can use throughout a make file. I&#8217;m going to show you just this and a couple</p>



<p class="wp-block-paragraph">other ones, but basically this means don&#8217;t print the command you&#8217;re about to</p>



<p class="wp-block-paragraph">execute, just execute it. So let me show you an example real fast of what I&#8217;m</p>



<p class="wp-block-paragraph">what I&#8217;m talking about.</p>



<p class="wp-block-paragraph">Targets to show silence and non-silent commands,</p>



<p class="wp-block-paragraph">or a suppressed command, whatever you wanna call it.</p>



<p class="wp-block-paragraph">Basically not printing the command,</p>



<p class="wp-block-paragraph">just executing the command.</p>



<p class="wp-block-paragraph">So I&#8217;m gonna name a target silent commands,</p>



<p class="wp-block-paragraph">and it&#8217;s not gonna depend on anything.</p>



<p class="wp-block-paragraph">So that&#8217;s why I&#8217;m gonna hit enter here,</p>



<p class="wp-block-paragraph">just like with menu and unlike the default.</p>



<p class="wp-block-paragraph">So then I wanna do tab to enter a command</p>



<p class="wp-block-paragraph">to enter a command and the echo command is going to say hello this is a silent command or a</p>



<p class="wp-block-paragraph">suppressed command then i&#8217;m going to do basically the same thing again but i&#8217;m not going to put the</p>



<p class="wp-block-paragraph">at symbol in front i&#8217;m going to say hello this is a non-silent command so what we should see is that</p>



<p class="wp-block-paragraph">if we exit the silent commands target we should see first this message gets printed on line 75</p>



<p class="wp-block-paragraph">and then second we see the full command including the echo statement that shows up on line 76 and</p>



<p class="wp-block-paragraph">on line 76 and then third we should just see the message hello this is a non-silent command</p>



<p class="wp-block-paragraph">let me oh and then if it&#8217;s a phony target meaning it&#8217;s not an actual file on the file system</p>



<p class="wp-block-paragraph">that you expect to be built we have to do phony and phony is actually a target notice how i&#8217;m</p>



<p class="wp-block-paragraph">saying dot phony colon indicating that that it&#8217;s a target and we&#8217;ll just say that it depends on</p>



<p class="wp-block-paragraph">and we&#8217;ll just name the command that is also a phony or the target that&#8217;s also a phony</p>



<p class="wp-block-paragraph">you can specify all of the phony targets in one line if you really want to but for me that kind</p>



<p class="wp-block-paragraph">of feels messy and you&#8217;re allowed to like add add add dependencies so notice on line 70 i&#8217;m adding</p>



<p class="wp-block-paragraph">menu as a phony target and then on line 77 i&#8217;m adding silent commands as a phony target</p>



<p class="wp-block-paragraph">the way you do it is up to you but i like to do it this way so i&#8217;m going to do silent commands</p>



<p class="wp-block-paragraph">and then I&#8217;m going to do make silent commands.</p>



<p class="wp-block-paragraph">So now we&#8217;re actually going to execute the silent commands target</p>



<p class="wp-block-paragraph">so we wouldn&#8217;t see a menu.</p>



<p class="wp-block-paragraph">And then we&#8217;ll see an example of the silent commands.</p>



<p class="wp-block-paragraph">Notice how the first one that says,</p>



<p class="wp-block-paragraph">hello, this is a silent command.</p>



<p class="wp-block-paragraph">The actual echo command is nowhere to be found</p>



<p class="wp-block-paragraph">because that whole line was muted</p>



<p class="wp-block-paragraph">and only the output of executing the command gets shown to you.</p>



<p class="wp-block-paragraph">But for the second one,</p>



<p class="wp-block-paragraph">remember we did not put the at symbol on the second command.</p>



<p class="wp-block-paragraph">So the whole entire command gets printed.</p>



<p class="wp-block-paragraph">the whole entire command gets printed echo and then quote this is a non-silent command and then</p>



<p class="wp-block-paragraph">that command gets executed and here&#8217;s the result it&#8217;s the same string except just without the echo</p>



<p class="wp-block-paragraph">so you know this line right here is this is the command that we&#8217;re about to execute whoops</p>



<p class="wp-block-paragraph">this is the command we&#8217;re about to execute and then the last line is this is the result of</p>



<p class="wp-block-paragraph">executing that command why would you want to print your commands kind of useful sometimes to see the</p>



<p class="wp-block-paragraph">compiler statements that show up there have been a few times or more than a few times in my life</p>



<p class="wp-block-paragraph">times in my life where I was running a make file and just kind of watching it and it was printing</p>



<p class="wp-block-paragraph">out all the commands that it was executing and then I realized oh my god that&#8217;s wrong because</p>



<p class="wp-block-paragraph">it was printing and I was able to fix that so you know you don&#8217;t have to print your commands but</p>



<p class="wp-block-paragraph">you probably want to so let&#8217;s see what else can we do okay so here&#8217;s another thing that I want to</p>



<p class="wp-block-paragraph">show you how to ignore failures so sometimes if you&#8217;re compiling your source code won&#8217;t compile</p>



<p class="wp-block-paragraph">So then that means the compilation command failed.</p>



<p class="wp-block-paragraph">Or if you want to do any command in general,</p>



<p class="wp-block-paragraph">and for some reason it returns false or it fails,</p>



<p class="wp-block-paragraph">then that&#8217;s considered a failed command.</p>



<p class="wp-block-paragraph">The make build system will stop execution of any target</p>



<p class="wp-block-paragraph">as soon as it encounters a failure.</p>



<p class="wp-block-paragraph">It&#8217;s kind of a good thing.</p>



<p class="wp-block-paragraph">What if you had a huge complicated target,</p>



<p class="wp-block-paragraph">which you can do it this way.</p>



<p class="wp-block-paragraph">I&#8217;ve done it this way before.</p>



<p class="wp-block-paragraph">What if you had a huge complicated target,</p>



<p class="wp-block-paragraph">which not only builds everything,</p>



<p class="wp-block-paragraph">but then also tries to deploy it to your remote server?</p>



<p class="wp-block-paragraph">deploy it to your remote server.</p>



<p class="wp-block-paragraph">Well, if your program fails to build, you probably don&#8217;t want the deployment part to</p>



<p class="wp-block-paragraph">execute.</p>



<p class="wp-block-paragraph">So you would hope that it would stop as soon as something failed to compile.</p>



<p class="wp-block-paragraph">Right.</p>



<p class="wp-block-paragraph">So we should try to know the difference between failed commands stopping the make build system</p>



<p class="wp-block-paragraph">and failed commands being ignored by the build system and just continuing.</p>



<p class="wp-block-paragraph">So we can do it both ways.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to do a little comment here.</p>



<p class="wp-block-paragraph">or ignoring failures and then i&#8217;m going to do ignore failures so that&#8217;s a target no dependencies</p>



<p class="wp-block-paragraph">and i&#8217;m just going to do false false twice in bash if you just you know do a false</p>



<p class="wp-block-paragraph">then it will be interpreted as a failure um so you know if i put true here it will be interpreted</p>



<p class="wp-block-paragraph">as true and this is not necessarily a make file thing this is a bash thing just like the command</p>



<p class="wp-block-paragraph">just like the command line. Let me show you real fast just just to prove it. I&#8217;m gonna prove it to</p>



<p class="wp-block-paragraph">you. Okay, so hopefully you remember if you can do echo dollar sign question, it&#8217;ll tell you the</p>



<p class="wp-block-paragraph">return code of the last command that you executed. So if I type echo hello, and then as another</p>



<p class="wp-block-paragraph">command, I echo the return code of the previous command. Now it&#8217;s going to basically tell me</p>



<p class="wp-block-paragraph">echo and then it&#8217;s going to tell me whether or not echo succeeded. You see a zero indicating</p>



<p class="wp-block-paragraph">succeeded it would be really weird if it didn&#8217;t succeed but you know whatever now i can modify</p>



<p class="wp-block-paragraph">this command just to type in some random stuff like what if i type in this notice how the second</p>



<p class="wp-block-paragraph">part the echo return code part echoes a 127 anything but a zero is considered a failure</p>



<p class="wp-block-paragraph">usually so it&#8217;s telling me 127 and that&#8217;s sometimes a standard code meaning something</p>



<p class="wp-block-paragraph">wasn&#8217;t found i could also just do true and that should give me a zero because you know in bash it</p>



<p class="wp-block-paragraph">bash it understands boolean so it&#8217;s like true success that&#8217;s a return code of zero it&#8217;s weird</p>



<p class="wp-block-paragraph">but that&#8217;s what it is if i return if i execute false then the return code should at least not</p>



<p class="wp-block-paragraph">be zero it&#8217;s probably going to be a one yeah there we go so just letting you know if we just</p>



<p class="wp-block-paragraph">execute the statement false by itself or true by itself then that&#8217;s telling us</p>



<p class="wp-block-paragraph">um that&#8217;s sort of like simulating a failed compile command or something i guess we could put</p>



<p class="wp-block-paragraph">commands in there if we wanted to but i don&#8217;t really want to run the compiler just for this</p>



<p class="wp-block-paragraph">in the compiler just for this so then I&#8217;m gonna do echo this echo statement</p>



<p class="wp-block-paragraph">should be reached as previous errors which I&#8217;m using false to represent should</p>



<p class="wp-block-paragraph">be ignored so now why how do I know that we&#8217;re gonna ignore the errors because I</p>



<p class="wp-block-paragraph">put the little minus in front of the false notice how before it was either an</p>



<p class="wp-block-paragraph">at symbol or nothing at the beginning of a command remember the at symbol does</p>



<p class="wp-block-paragraph">Remember the at symbol does suppression.</p>



<p class="wp-block-paragraph">The minus symbol says try to run this command,</p>



<p class="wp-block-paragraph">but if it fails, ignore it,</p>



<p class="wp-block-paragraph">continue with the recipe for that build target.</p>



<p class="wp-block-paragraph">You know, recipe meaning all of the commands</p>



<p class="wp-block-paragraph">that you want it to execute.</p>



<p class="wp-block-paragraph">So that means the ignore failures target</p>



<p class="wp-block-paragraph">should actually fail twice and then make it to line 84</p>



<p class="wp-block-paragraph">where it just prints that message.</p>



<p class="wp-block-paragraph">Then we&#8217;ll do, well, we&#8217;ll mark this as a phony target.</p>



<p class="wp-block-paragraph">practice to try to mark your phony targets i&#8217;ve i&#8217;ve not done that in the past and eventually</p>



<p class="wp-block-paragraph">regretted it a few times so then i&#8217;m going to do stop on failures is another target and we&#8217;re going</p>



<p class="wp-block-paragraph">to do false whoops no minus because we actually want to stop on failure false and then we&#8217;ll do</p>



<p class="wp-block-paragraph">another echo and we&#8217;ll say this echo statement should never be reached as previous errors</p>



<p class="wp-block-paragraph">false should cause build build termination okay I&#8217;m kind of verbose but I hope this explains it</p>



<p class="wp-block-paragraph">we&#8217;ll name this as a phony target too phony you&#8217;re a phony failures okay so we can run both these</p>



<p class="wp-block-paragraph">maybe I&#8217;ll put a comment here just to show you it&#8217;s two separate things I kind of like doing that</p>



<p class="wp-block-paragraph">we can run ignore failures and then we can run stop on failures separately to see what happens</p>



<p class="wp-block-paragraph">Let me get rid of this terminal window.</p>



<p class="wp-block-paragraph">Okay, so I&#8217;m going to do clear and, what was it?</p>



<p class="wp-block-paragraph">Ignore failures and then stop on failures.</p>



<p class="wp-block-paragraph">So ignore failures, notice how it prints false</p>



<p class="wp-block-paragraph">because I forgot to put an at symbol in front of it.</p>



<p class="wp-block-paragraph">And then the make system itself says,</p>



<p class="wp-block-paragraph">hey, error, that command failed, error one.</p>



<p class="wp-block-paragraph">Remember before we had the return code one</p>



<p class="wp-block-paragraph">when we just typed in false.</p>



<p class="wp-block-paragraph">me that it received return code one from trying to execute false inside of bash so it detected</p>



<p class="wp-block-paragraph">that a failure occurred so these two lines go together then the same thing again because i have</p>



<p class="wp-block-paragraph">two false statements in there and then the last statement says this echo statement should be</p>



<p class="wp-block-paragraph">reached as previous errors should be ignored because we use the minus symbol i&#8217;m having a</p>



<p class="wp-block-paragraph">hard time selecting text here i gotta i gotta go home and practice my text selection actually wait</p>



<p class="wp-block-paragraph">So notice how, you know, the minus symbol right there says, let&#8217;s ignore.</p>



<p class="wp-block-paragraph">So now let&#8217;s do stop on failures.</p>



<p class="wp-block-paragraph">Stop on failures.</p>



<p class="wp-block-paragraph">Notice how the first false showed up as an error to the make build system.</p>



<p class="wp-block-paragraph">And then make just said, we&#8217;re done.</p>



<p class="wp-block-paragraph">We&#8217;re not ignoring this error.</p>



<p class="wp-block-paragraph">We&#8217;re just done.</p>



<p class="wp-block-paragraph">So keep that in mind.</p>



<p class="wp-block-paragraph">Anytime you have commands that need to stop the build, if they fail,</p>



<p class="wp-block-paragraph">build if they fail you should not put a minus in front but anytime you have commands where</p>



<p class="wp-block-paragraph">everything just needs to be executed even if some stuff fails you want to put a minus in front of</p>



<p class="wp-block-paragraph">there we&#8217;ll talk about a clean target a little bit later which usually you know just continues</p>



<p class="wp-block-paragraph">even if there&#8217;s a failure so we got silent commands ignored commands or ignored failures</p>



<p class="wp-block-paragraph">and failures that we&#8217;re actually going to stop so now we&#8217;re going to get into the the meat and</p>



<p class="wp-block-paragraph">make file it doesn&#8217;t really do anything it doesn&#8217;t build anything for us I&#8217;m just kind of showing you</p>



<p class="wp-block-paragraph">you know how to work with the make file like the very basics now let&#8217;s actually start to build</p>



<p class="wp-block-paragraph">things so the first thing I&#8217;d like to do is I&#8217;d like to make a target for the build directory</p>



<p class="wp-block-paragraph">if you you know again if you just kind of like look at my file system here I don&#8217;t actually have</p>



<p class="wp-block-paragraph">a build directory right so I want to make sure that a build directory exists I could of course</p>



<p class="wp-block-paragraph">dir and then type build but I want the build system to do this automatically for me and also</p>



<p class="wp-block-paragraph">as a lesson for what we&#8217;re doing so you know be sure the build directory exists so I&#8217;m going to</p>



<p class="wp-block-paragraph">name a target and this is not going to be a phony target I think this is our first non-phony target</p>



<p class="wp-block-paragraph">right yeah oh I forgot to put la default as a phony might regret that one day the defaults</p>



<p class="wp-block-paragraph">you is phony and everything&#8217;s funny. Okay. So now we have our first real build target. I&#8217;m just</p>



<p class="wp-block-paragraph">going to name the thing that I want to build. And I&#8217;m going to name it by typing the build directory</p>



<p class="wp-block-paragraph">variable. I could type, you know, underscore build or whatever it is that I put for that variable.</p>



<p class="wp-block-paragraph">What did I put there again? Underscore build. Yeah, I could put that if I wanted to. But again,</p>



<p class="wp-block-paragraph">try not to hard code things. It&#8217;s better to stick things in variables if you can.</p>



<p class="wp-block-paragraph">So since this is a target, I&#8217;m going to put a colon. It doesn&#8217;t really depend on anything,</p>



<p class="wp-block-paragraph">because if we&#8217;re just talking about building that folder all we really have to do is execute a command</p>



<p class="wp-block-paragraph">to just make sure that the folder is created right so i&#8217;m going to do no dependencies and</p>



<p class="wp-block-paragraph">then i&#8217;m going to like maybe do a little all say function call just to announce that we&#8217;re going</p>



<p class="wp-block-paragraph">to ensure the build directory a lot of people don&#8217;t do this but i&#8217;m going to do it ensuring</p>



<p class="wp-block-paragraph">the builder and now i could put you know what the builder is probably a pretty good idea so that i</p>



<p class="wp-block-paragraph">probably a pretty good idea so that I can see what I&#8217;m trying to ensure let&#8217;s</p>



<p class="wp-block-paragraph">just run that real fast if I say oh shoot I guess I would have to do make</p>



<p class="wp-block-paragraph">and then name build let&#8217;s see if that actually works yeah okay so I&#8217;m naming</p>



<p class="wp-block-paragraph">the build directory you wouldn&#8217;t normally actually name the build</p>



<p class="wp-block-paragraph">directory in the command line but I&#8217;m doing it so it says we&#8217;re ensuring the</p>



<p class="wp-block-paragraph">build directory and then now it says the build thing is up to date because the</p>



<p class="wp-block-paragraph">because the target finished executing,</p>



<p class="wp-block-paragraph">but nothing actually got created, right?</p>



<p class="wp-block-paragraph">So what I would like to do before we actually create it</p>



<p class="wp-block-paragraph">is replace this builder variable with a special variable</p>



<p class="wp-block-paragraph">that GNU make gives you called $at.</p>



<p class="wp-block-paragraph">The $at variable, and I&#8217;m quoting it,</p>



<p class="wp-block-paragraph">you don&#8217;t have to quote it,</p>



<p class="wp-block-paragraph">it always ends up being the name of the current build target.</p>



<p class="wp-block-paragraph">So again, it&#8217;s a bad idea to hard code</p>



<p class="wp-block-paragraph">It&#8217;s a bad idea to hard code lots of different values</p>



<p class="wp-block-paragraph">and it&#8217;s way better to put things into a variable.</p>



<p class="wp-block-paragraph">But at the same time, if you can get away with</p>



<p class="wp-block-paragraph">hard coding a variable name multiple times</p>



<p class="wp-block-paragraph">and you can use something more generic,</p>



<p class="wp-block-paragraph">well then that can also increase the power</p>



<p class="wp-block-paragraph">of what you&#8217;re doing, make things easier for you</p>



<p class="wp-block-paragraph">and easier for you to debug.</p>



<p class="wp-block-paragraph">Save yourself some time, right?</p>



<p class="wp-block-paragraph">Because coding is already hard enough.</p>



<p class="wp-block-paragraph">So if I do dollar sign at,</p>



<p class="wp-block-paragraph">it should show up as whatever the builder contains</p>



<p class="wp-block-paragraph">because that&#8217;s the current target.</p>



<p class="wp-block-paragraph">So let&#8217;s run that one more time.</p>



<p class="wp-block-paragraph">that one more time and we&#8217;ll say clear and make build notice how it says ensuring the builder and</p>



<p class="wp-block-paragraph">then it quoted the current target which is underscore built nice so we got that now let&#8217;s</p>



<p class="wp-block-paragraph">actually run a command to create the directory that&#8217;s just going to be you know in linux the</p>



<p class="wp-block-paragraph">command mkdir to make a directory and again i could put a builder here but it&#8217;s probably a</p>



<p class="wp-block-paragraph">special variable that will change because what if later on i want to change the name of that variable</p>



<p class="wp-block-paragraph">uh if i did then i&#8217;d have to change it in three places now but uh you know and possibly way more</p>



<p class="wp-block-paragraph">places later down the line but if i use that special you know dollar at symbol then i only</p>



<p class="wp-block-paragraph">have to change it in one spot okay so mkdir so that basically says it&#8217;s going to look to see if</p>



<p class="wp-block-paragraph">that folder is created if it&#8217;s not then it&#8217;s going to create it with that command so if i do that</p>



<p class="wp-block-paragraph">So if I do that, notice how it executed that command and also printed the command.</p>



<p class="wp-block-paragraph">So it&#8217;s like mkdir build.</p>



<p class="wp-block-paragraph">If we list the directory again, notice how there is a build directory.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">You go inside of there.</p>



<p class="wp-block-paragraph">Everything&#8217;s fine.</p>



<p class="wp-block-paragraph">I&#8217;m going to remove it real fast.</p>



<p class="wp-block-paragraph">Whoops.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">All right.</p>



<p class="wp-block-paragraph">our make file until it&#8217;s somewhat decent it&#8217;s not going to be amazing but it&#8217;s going to be somewhat</p>



<p class="wp-block-paragraph">decent okay so we have a target that will build the build directory now let&#8217;s make our first real</p>



<p class="wp-block-paragraph">target that is it&#8217;s going to be a phony target but it&#8217;s going to it&#8217;s going to do something for us</p>



<p class="wp-block-paragraph">so run the program we&#8217;re going to make a target called run and so if you type make run then it</p>



<p class="wp-block-paragraph">which in my opinion would be building the program first.</p>



<p class="wp-block-paragraph">Your opinion may vary, but you know, so I&#8217;m going to do it this way.</p>



<p class="wp-block-paragraph">I&#8217;m going to say run colon because that&#8217;s the name of the target.</p>



<p class="wp-block-paragraph">And I&#8217;m going to say that the run target depends on the build target.</p>



<p class="wp-block-paragraph">So remember this means that before run can actually execute its steps,</p>



<p class="wp-block-paragraph">it will go quickly to the build target and execute all the steps in its recipe.</p>



<p class="wp-block-paragraph">So essentially I&#8217;m saying before we try to run, let&#8217;s build.</p>



<p class="wp-block-paragraph">So it depends on build.</p>



<p class="wp-block-paragraph">By the way, build is not created yet.</p>



<p class="wp-block-paragraph">We&#8217;re going to do that in a second.</p>



<p class="wp-block-paragraph">not created yet we&#8217;re going to do that in a second the only line in this recipe that i&#8217;m going to put</p>



<p class="wp-block-paragraph">is just the name of the binary meaning after build is finished running i can assume that</p>



<p class="wp-block-paragraph">the entire executable is actually built and it&#8217;s ready to run so then i&#8217;m just going to run it so</p>



<p class="wp-block-paragraph">it&#8217;s just like first go build it somewhere else and then run it and again indirection and modular</p>



<p class="wp-block-paragraph">thinking is is a lot more powerful than just sticking all the build commands right inside of</p>



<p class="wp-block-paragraph">run target and duplicate all those commands for the build target so this is way better and then</p>



<p class="wp-block-paragraph">i&#8217;ll name run as a phony because this is not an actual file i&#8217;m trying to build the run the there&#8217;s</p>



<p class="wp-block-paragraph">no file named run then we&#8217;ll do the build target build and link the object files and executable</p>



<p class="wp-block-paragraph">okay and this is where it gets a little funny so we&#8217;re going to make a target called build</p>



<p class="wp-block-paragraph">actually build everything we shouldn&#8217;t hard code them here we should treat every source code file</p>



<p class="wp-block-paragraph">as as one separate thing that needs to be built every corresponding object file that comes from</p>



<p class="wp-block-paragraph">a source file should be one separate thing that that gets built from the source code that needs</p>



<p class="wp-block-paragraph">to be used to build i guess is what i should say so what should the build target depend on like</p>



<p class="wp-block-paragraph">before we can say that build is satisfied.</p>



<p class="wp-block-paragraph">How about just the executable file itself?</p>



<p class="wp-block-paragraph">So I&#8217;m going to say the bin.</p>



<p class="wp-block-paragraph">So our main program,</p>



<p class="wp-block-paragraph">it should be totally built and finished</p>



<p class="wp-block-paragraph">and set up and created and everything</p>



<p class="wp-block-paragraph">before we can say build is satisfied.</p>



<p class="wp-block-paragraph">And then hilariously, once that&#8217;s satisfied,</p>



<p class="wp-block-paragraph">then the build target is totally satisfied too</p>



<p class="wp-block-paragraph">because it doesn&#8217;t really do anything.</p>



<p class="wp-block-paragraph">It just asks, you know, this is more of a shortcut.</p>



<p class="wp-block-paragraph">Okay, so now let&#8217;s,</p>



<p class="wp-block-paragraph">Let&#8217;s maybe first before we link let&#8217;s start writing commands to actually build the source code files. So I&#8217;m gonna do</p>



<p class="wp-block-paragraph">build the first object file</p>



<p class="wp-block-paragraph">So remember we have three source code files here. We&#8217;ve got first dot CPP and</p>



<p class="wp-block-paragraph">Second dot C and third dot ASM. So that&#8217;s just three source code files. They should map to three object files</p>



<p class="wp-block-paragraph">Let me let me draw this for you for a second before we talk about it further because I want to make sure</p>



<p class="wp-block-paragraph">that what I&#8217;m about to do is crystal clear when we&#8217;re talking about like the dependency graph.</p>



<p class="wp-block-paragraph">Okay. So my mouse is all over the place. I gotta execute a command real fast.</p>



<p class="wp-block-paragraph">I have many monitors going on right now and the pen just keeps forgetting that it&#8217;s only</p>



<p class="wp-block-paragraph">supposed to be on this one monitor. Okay. So I got that. Okay. So the first thing that we</p>



<p class="wp-block-paragraph">executable called main.</p>



<p class="wp-block-paragraph">So I&#8217;m just going to draw that on the graph here for you Windows people.</p>



<p class="wp-block-paragraph">You can imagine there&#8217;s a dot exe on the end of it, but in, you know, in Linux and</p>



<p class="wp-block-paragraph">other link and other operating systems, we don&#8217;t really need that.</p>



<p class="wp-block-paragraph">So main, we want to build that.</p>



<p class="wp-block-paragraph">That&#8217;s the, that&#8217;s the primary thing we&#8217;re trying to build.</p>



<p class="wp-block-paragraph">What does it depend on though?</p>



<p class="wp-block-paragraph">What needs to be built before we can, we can create our executable?</p>



<p class="wp-block-paragraph">Well, we need to compile every piece of source code into a corresponding</p>



<p class="wp-block-paragraph">all the object files will be linked together into the executable so maybe i&#8217;ll i&#8217;ll write</p>



<p class="wp-block-paragraph">down first what the uh what the source code files are going to be so i&#8217;m going to do let&#8217;s see first</p>



<p class="wp-block-paragraph">sorry about my writing i don&#8217;t have a smoother right now first dot cpp and i got like a really</p>



<p class="wp-block-paragraph">small draw pad um i&#8217;m i&#8217;m making lots of excuses but i think probably my penmanship in real life is</p>



<p class="wp-block-paragraph">maybe even a little worse i don&#8217;t know i was at a job a long time ago and i was taking down</p>



<p class="wp-block-paragraph">names of customers it was like a tech support center and my boss after he saw the paper that</p>



<p class="wp-block-paragraph">i was writing down he just looked at me and he went chicken scratches and then he walked away</p>



<p class="wp-block-paragraph">okay so we have first dot cpp and then we have second this is why i like typing second dot c</p>



<p class="wp-block-paragraph">okay so we got that and then we&#8217;ll have third dot asm so third maybe i should go slower a</p>



<p class="wp-block-paragraph">At least I&#8217;m not making misspellings.</p>



<p class="wp-block-paragraph">I know these are simple file names, but it could happen.</p>



<p class="wp-block-paragraph">So we have three source code files.</p>



<p class="wp-block-paragraph">They don&#8217;t really depend on anything because they just are themselves.</p>



<p class="wp-block-paragraph">We don&#8217;t need to build these source code files.</p>



<p class="wp-block-paragraph">So we&#8217;re not going to draw any arrows indicating that these files depend on something else.</p>



<p class="wp-block-paragraph">They&#8217;re kind of like the primary source.</p>



<p class="wp-block-paragraph">Like these are the things that would actually go into your Git repository,</p>



<p class="wp-block-paragraph">whereas the object files that we&#8217;re going to generate and the executable that we generate,</p>



<p class="wp-block-paragraph">they would definitely not go into your repository.</p>



<p class="wp-block-paragraph">your git repository. Okay, so what&#8217;s going to happen? First.cpp is going to generate first.o.</p>



<p class="wp-block-paragraph">We&#8217;re going to type that out in a second, but basically first.o. That&#8217;s awful. That just looks</p>



<p class="wp-block-paragraph">disgusting. I&#8217;m going to keep it though. Okay, so in order to indicate dependency,</p>



<p class="wp-block-paragraph">we&#8217;re going to draw an arrow from first.o to first.cpp indicating, all right,</p>



<p class="wp-block-paragraph">if we&#8217;re trying to build first.o, then it will look at first.cpp and it&#8217;ll check.</p>



<p class="wp-block-paragraph">check does it exist if it doesn&#8217;t then there&#8217;s an error if it does exist then then the the the</p>



<p class="wp-block-paragraph">build system is actually going to check the modification dates of first.o and first.cpp</p>



<p class="wp-block-paragraph">assuming that a first.o already exists it&#8217;s just going to check it&#8217;s going to say</p>



<p class="wp-block-paragraph">does is first.cpp newer than first.o if yes then that means i have to recompile first.o if no i&#8217;m</p>



<p class="wp-block-paragraph">not going to recompile it and i&#8217;m going to save a bunch of time this is kind of the heart of why</p>



<p class="wp-block-paragraph">So same thing for 2nd.0.</p>



<p class="wp-block-paragraph">2nd.0, I&#8217;ll just circle it here, and we&#8217;ll say that it depends on 2nd.c.</p>



<p class="wp-block-paragraph">And then, of course, the 3rd.0 object file, it&#8217;s going to depend on 3rd.asm.</p>



<p class="wp-block-paragraph">So again, notice how they don&#8217;t really depend on each other.</p>



<p class="wp-block-paragraph">Maybe if you have a C++ file, maybe if you have a C++ program that&#8217;s really complicated,</p>



<p class="wp-block-paragraph">maybe your first.o, it would depend on the CPP file,</p>



<p class="wp-block-paragraph">and it might also depend on some other header files that you have set up somewhere.</p>



<p class="wp-block-paragraph">So then there would be more circles and more arrows that we draw.</p>



<p class="wp-block-paragraph">But for now, it&#8217;s just a simple program, so I&#8217;m just going to leave it this way.</p>



<p class="wp-block-paragraph">But just keep in mind that when we name dependencies in the make file,</p>



<p class="wp-block-paragraph">you want to name a dependency of everything that a source file depends on.</p>



<p class="wp-block-paragraph">So like first.o, it&#8217;s definitely going to depend on first.cpp,</p>



<p class="wp-block-paragraph">includes that are custom or from someone&#8217;s library and not the C++ standard libraries,</p>



<p class="wp-block-paragraph">then you would want to say that first.o depends on those as well. Because if you change</p>



<p class="wp-block-paragraph">a header that you made elsewhere in the program, then you probably want to recompile</p>



<p class="wp-block-paragraph">that corresponding object file, right? So just keep that in mind.</p>



<p class="wp-block-paragraph">Anyway, we&#8217;ll do first.o. Okay, so now the executable program main, that needs to be</p>



<p class="wp-block-paragraph">all the object files so I can just say that it depends on all three object files</p>



<p class="wp-block-paragraph">with just this right here and this is the basic idea of what we&#8217;re about to</p>



<p class="wp-block-paragraph">type up in the make file itself keep in mind that the make system will actually</p>



<p class="wp-block-paragraph">build this graph in memory under the hood to try and figure out which things</p>



<p class="wp-block-paragraph">actually need to be built or not you could even launch make with multiple</p>



<p class="wp-block-paragraph">threads I&#8217;ll probably forget to do it but it&#8217;s a things like dash J and then</p>



<p class="wp-block-paragraph">things like dash j and then the number of threads you want to launch in order to totally saturate</p>



<p class="wp-block-paragraph">your cpu and have as many things compiling as possibly can be compiled make will figure out</p>



<p class="wp-block-paragraph">which things don&#8217;t actually depend on each other and then build them in separate threads at the</p>



<p class="wp-block-paragraph">same time so your build system is just like so much faster so let&#8217;s see we got uh corresponding</p>



<p class="wp-block-paragraph">object dial for every source file and then we got the binary that depends on the object notice how</p>



<p class="wp-block-paragraph">source code file what would happen is when we wanted to build the let&#8217;s say we wanted to just</p>



<p class="wp-block-paragraph">you know this is the the target the binary target that is just named main what will happen is it&#8217;ll</p>



<p class="wp-block-paragraph">look at its dependencies and the way we&#8217;re going to write it it&#8217;ll say okay it depends on the three</p>



<p class="wp-block-paragraph">object files if they&#8217;re already there and they&#8217;re already satisfied then it it won&#8217;t actually</p>



<p class="wp-block-paragraph">if they&#8217;re already there and they are all newer than their corresponding source files then none</p>



<p class="wp-block-paragraph">corresponding source files, then none of them will get rebuilt. If main itself sees that it is newer,</p>



<p class="wp-block-paragraph">like the existing on disk version of main is newer than all the object files, then that tells the</p>



<p class="wp-block-paragraph">build system, oh, I don&#8217;t actually even need to relink the binary at all because the object files</p>



<p class="wp-block-paragraph">didn&#8217;t change, which means the source code didn&#8217;t change. And so you could actually like type make</p>



<p class="wp-block-paragraph">build and nothing happens because nothing needs to happen. It&#8217;s going to be pretty cool. I&#8217;ll show</p>



<p class="wp-block-paragraph">I&#8217;ll show you in a moment.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So for now, I&#8217;m going to try not to erase this.</p>



<p class="wp-block-paragraph">I&#8217;m going to do a toggle.</p>



<p class="wp-block-paragraph">Do I can, I don&#8217;t know if I remember, I think it&#8217;s like control.</p>



<p class="wp-block-paragraph">Let me do the menu here.</p>



<p class="wp-block-paragraph">I don&#8217;t want to screw it up.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">It would have been control.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So I&#8217;m going to toggle visibility.</p>



<p class="wp-block-paragraph">Just get that off there.</p>



<p class="wp-block-paragraph">Just in case I want to show it to you again later.</p>



<p class="wp-block-paragraph">So now let&#8217;s make the first object file.</p>



<p class="wp-block-paragraph">So remember the first object file is first.o.</p>



<p class="wp-block-paragraph">to create a target that will build the object file based on the first source code file.</p>



<p class="wp-block-paragraph">I&#8217;m going to put a colon there to indicate that it&#8217;s a target.</p>



<p class="wp-block-paragraph">And then remember on the right side, we can do dependencies.</p>



<p class="wp-block-paragraph">Well, we have to say that this depends on the first CPP file.</p>



<p class="wp-block-paragraph">If we didn&#8217;t, then every single time we run the make system,</p>



<p class="wp-block-paragraph">then this object file is just going to get built over and over and over again,</p>



<p class="wp-block-paragraph">even if it doesn&#8217;t need to.</p>



<p class="wp-block-paragraph">So now with a dependency there, it&#8217;s going to look at first.cpp</p>



<p class="wp-block-paragraph">and then it&#8217;s going to look at first.o if one exists if one doesn&#8217;t exist it&#8217;ll</p>



<p class="wp-block-paragraph">definitely build it but if one does exist it&#8217;ll go is first.o newer than</p>



<p class="wp-block-paragraph">first.cpp if it is don&#8217;t do anything but if it&#8217;s not then rebuild it make sure</p>



<p class="wp-block-paragraph">it&#8217;s fresh here&#8217;s the other thing though I kind of wanted to build everything</p>



<p class="wp-block-paragraph">inside of the of the build folder so I&#8217;m gonna add the variable build in front of</p>



<p class="wp-block-paragraph">it let me do it first without doing that so that you can kind of see what will</p>



<p class="wp-block-paragraph">So it&#8217;s going to depend on first dot CPP.</p>



<p class="wp-block-paragraph">And then there&#8217;s another thing you can do in make files where you can,</p>



<p class="wp-block-paragraph">I forgot the proper name for this,</p>



<p class="wp-block-paragraph">but you can specify other types of dependencies where they only need to exist</p>



<p class="wp-block-paragraph">as a dependency.</p>



<p class="wp-block-paragraph">They don&#8217;t necessarily need to be freshly fully updated because,</p>



<p class="wp-block-paragraph">you know, the way files and folders work,</p>



<p class="wp-block-paragraph">if you start adding or removing files from a directory,</p>



<p class="wp-block-paragraph">then the directory thinks that it&#8217;s been updated.</p>



<p class="wp-block-paragraph">And so that can kind of throw off the build system&#8217;s thinking</p>



<p class="wp-block-paragraph">the build system&#8217;s thinking because your build directory will always think that it&#8217;s been updated</p>



<p class="wp-block-paragraph">if anything happens. But we don&#8217;t really care about the date of when the build directory was</p>



<p class="wp-block-paragraph">built. We just want to make sure that it exists, right? So we put a little or bar and we put those</p>



<p class="wp-block-paragraph">types of dependencies on the right side of the or bar. Okay, maybe I&#8217;ll leave a comment or something</p>



<p class="wp-block-paragraph">at a later date specifying the official name for that, but I mean, that&#8217;s how it works.</p>



<p class="wp-block-paragraph">So that&#8217;s the recipe.</p>



<p class="wp-block-paragraph">It&#8217;s got dependencies.</p>



<p class="wp-block-paragraph">You know, in the past, I&#8217;ve said when you name a dependency,</p>



<p class="wp-block-paragraph">it goes off and make sure that that dependency is resolved.</p>



<p class="wp-block-paragraph">Well, that&#8217;s true for phony targets and targets that sort of do other things.</p>



<p class="wp-block-paragraph">But in this case, if we&#8217;re just naming a file, all it&#8217;s going to do is just look</p>



<p class="wp-block-paragraph">at the modification date of the file.</p>



<p class="wp-block-paragraph">So now let&#8217;s do the recipe.</p>



<p class="wp-block-paragraph">I&#8217;m going to do CPP, which means that&#8217;s the C++ compiler.</p>



<p class="wp-block-paragraph">And I could write, you know, G++ and all the commands here directly</p>



<p class="wp-block-paragraph">directly if I want to, but it&#8217;s kind of a waste of time.</p>



<p class="wp-block-paragraph">And it&#8217;s not, it&#8217;s not very smart because we said before, what if you want to change</p>



<p class="wp-block-paragraph">the flags and you have a hundred objects that you&#8217;re building, you probably just want to</p>



<p class="wp-block-paragraph">be able to change one variable instead of a hundred different things.</p>



<p class="wp-block-paragraph">So we&#8217;ll do CPP flags and then we&#8217;ll, let&#8217;s see, we&#8217;ll take first.cpp as a source.</p>



<p class="wp-block-paragraph">You can imagine again, this is like, you know, G++ happening inside of here and then wall</p>



<p class="wp-block-paragraph">inside of here.</p>



<p class="wp-block-paragraph">and then at some point you specify the source.</p>



<p class="wp-block-paragraph">Okay, so just keep that in mind.</p>



<p class="wp-block-paragraph">And then after I specify the source,</p>



<p class="wp-block-paragraph">I want to specify the output</p>



<p class="wp-block-paragraph">and the output is going to be first.o.</p>



<p class="wp-block-paragraph">And now let&#8217;s use another trick</p>



<p class="wp-block-paragraph">which allows us to make slightly more powerful make files.</p>



<p class="wp-block-paragraph">So again, you want to avoid hard coding stuff if you can.</p>



<p class="wp-block-paragraph">There&#8217;s a special variable.</p>



<p class="wp-block-paragraph">Well, okay, let&#8217;s go back first to the other special variable.</p>



<p class="wp-block-paragraph">Remember $and, or sorry, $at.</p>



<p class="wp-block-paragraph">that always refers to the current target right so first.o is the is the current</p>



<p class="wp-block-paragraph">target so I don&#8217;t even have to type first.o here I can just do dollar sign</p>



<p class="wp-block-paragraph">at there&#8217;s another special variable which just basically means the first</p>



<p class="wp-block-paragraph">dependency that&#8217;s been named so if I just do quotes and then I say this it&#8217;s</p>



<p class="wp-block-paragraph">weird I know dollar sign and then angle bracket pointing to the left or like a</p>



<p class="wp-block-paragraph">typing first dot CPP. If you wanted to send a bunch more stuff, like if you wanted to</p>



<p class="wp-block-paragraph">send all of the names of all dependencies that you named into the command line, then</p>



<p class="wp-block-paragraph">you can use the carrot like dollar carrot. That&#8217;ll do all of the dependencies. But if</p>



<p class="wp-block-paragraph">we&#8217;re just compiling one source code file, you probably want to just do one dependency.</p>



<p class="wp-block-paragraph">Like for example, if I had other thing dot HPP as a dependency, I probably wouldn&#8217;t want</p>



<p class="wp-block-paragraph">because then that would be telling the compiler,</p>



<p class="wp-block-paragraph">here, I want you to compile first.cpp and also other thing.hpp,</p>



<p class="wp-block-paragraph">which probably wouldn&#8217;t work.</p>



<p class="wp-block-paragraph">It&#8217;s probably not what you want.</p>



<p class="wp-block-paragraph">So instead, if I do this like arrow to the left,</p>



<p class="wp-block-paragraph">then it will only give it first.cpp rather than both dependencies.</p>



<p class="wp-block-paragraph">But I guess we&#8217;re simple.</p>



<p class="wp-block-paragraph">We don&#8217;t really need all that right now.</p>



<p class="wp-block-paragraph">So we got that finished.</p>



<p class="wp-block-paragraph">Let&#8217;s see.</p>



<p class="wp-block-paragraph">We now have the binary.</p>



<p class="wp-block-paragraph">okay this is only going to run if i do make first dot oh maybe i should do that right now so that</p>



<p class="wp-block-paragraph">we can we can take more baby steps to making this more complicated so i&#8217;ll do here and make</p>



<p class="wp-block-paragraph">and then i&#8217;ll do make first dot o so notice how when i typed first dot o it went right to this</p>



<p class="wp-block-paragraph">target no problem and then it started to you know it looked at first dot cpp just to see you know</p>



<p class="wp-block-paragraph">built or not and it it also looked at the build directory as a dependency and</p>



<p class="wp-block-paragraph">then finally it actually compiled so what we should see right now is first</p>



<p class="wp-block-paragraph">dot o sitting in the directory and then also we should see the build directory</p>



<p class="wp-block-paragraph">again let&#8217;s just double check that so if I list everything notice how the build</p>



<p class="wp-block-paragraph">directory exists if I go remove and then remove the build directory and then</p>



<p class="wp-block-paragraph">clear it again notice how we also have first dot o so I can say remove first</p>



<p class="wp-block-paragraph">So if we go clear and list everything again, now I&#8217;m going to do one more time.</p>



<p class="wp-block-paragraph">Make first.o and then if I do list, then the first.o got built and the build directory got built.</p>



<p class="wp-block-paragraph">Notice also that as soon as I ran that command, it did make dir on build.</p>



<p class="wp-block-paragraph">So it built the build directory.</p>



<p class="wp-block-paragraph">So that was the build dir target.</p>



<p class="wp-block-paragraph">And then it went over to the first.o target and it executed that command to actually compile it.</p>



<p class="wp-block-paragraph">All my variables expanded, so it&#8217;s like G++, wall, pedantic, whatever.</p>



<p class="wp-block-paragraph">That special variable with the arrow pointing to the left was the first source code, or source code file.</p>



<p class="wp-block-paragraph">And then the $at variable expanded to the current target, which is just first.o.</p>



<p class="wp-block-paragraph">If we run this again, I&#8217;m not going to clear it, I&#8217;m just going to go make first.o.</p>



<p class="wp-block-paragraph">Notice how nothing actually happens.</p>



<p class="wp-block-paragraph">It&#8217;s missing two lines.</p>



<p class="wp-block-paragraph">Up here we had two lines where we made the build directory</p>



<p class="wp-block-paragraph">and we also compiled the object file.</p>



<p class="wp-block-paragraph">But notice how here it just says the object file is up to date.</p>



<p class="wp-block-paragraph">It did not recompile it because it can tell that the source code was not changed.</p>



<p class="wp-block-paragraph">Let me go into another directory right here and I&#8217;ll just modify the source code file.</p>



<p class="wp-block-paragraph">I&#8217;ll just add an extra line to it and then I&#8217;ll go back here.</p>



<p class="wp-block-paragraph">and if I compile it now we should see that it chooses to compile it again</p>



<p class="wp-block-paragraph">because now the source code is newer than the object file so if I go make</p>



<p class="wp-block-paragraph">first notice how it did not build the build directory because it already</p>



<p class="wp-block-paragraph">existed but it did rebuild the object file because the source code was updated</p>



<p class="wp-block-paragraph">if I immediately try to build it again it does not need to rebuild it because</p>



<p class="wp-block-paragraph">the source code didn&#8217;t get updated since the last time I built and so it says</p>



<p class="wp-block-paragraph">it&#8217;s up to date up to date sometimes you might see a message that says something</p>



<p class="wp-block-paragraph">just says something like nothing to do, I think.</p>



<p class="wp-block-paragraph">So just keep that in mind.</p>



<p class="wp-block-paragraph">We&#8217;re getting a little bit better now.</p>



<p class="wp-block-paragraph">But I&#8217;m also making a mistake here</p>



<p class="wp-block-paragraph">because we have a build directory</p>



<p class="wp-block-paragraph">but there&#8217;s nothing inside of it.</p>



<p class="wp-block-paragraph">I wanna put everything inside of my build directory</p>



<p class="wp-block-paragraph">just to show you how annoying this could be.</p>



<p class="wp-block-paragraph">Notice how we got a first.cpp and a first.o.</p>



<p class="wp-block-paragraph">Imagine if you had a million source code files,</p>



<p class="wp-block-paragraph">you&#8217;ll have a million object files</p>



<p class="wp-block-paragraph">sitting in your repository or your directory</p>



<p class="wp-block-paragraph">kinda cluttering the place up, right?</p>



<p class="wp-block-paragraph">cluttering the place up, right? I don&#8217;t like it. I&#8217;m not a fan. You probably want to edit your</p>



<p class="wp-block-paragraph">git ignore so that you don&#8217;t accidentally put object files into your repo. But for me, I think</p>



<p class="wp-block-paragraph">it&#8217;s better to just ignore, git ignore a build directory, and then just stick everything inside</p>



<p class="wp-block-paragraph">of the build directory. It&#8217;s up to you, but this is the way I&#8217;m going to do it. So how do we get</p>



<p class="wp-block-paragraph">it to be inside of the build directory? First, let me remove the object file. Okay, let&#8217;s see,</p>



<p class="wp-block-paragraph">I think I can get rid of that. That&#8217;s responsible for the swap file. We probably want to put</p>



<p class="wp-block-paragraph">star.swap inside of gitignore so that the temporary files from nano don&#8217;t go into our</p>



<p class="wp-block-paragraph">repository. So now I&#8217;m going to prefix this object file. And a lot of people don&#8217;t do this,</p>



<p class="wp-block-paragraph">but I think it&#8217;s pretty cool. I&#8217;m going to do build dir slash the object. And then now</p>



<p class="wp-block-paragraph">everything&#8217;s going to show up inside of the builder or at least that one. So if I remove</p>



<p class="wp-block-paragraph">directory just kind of list things again then I can do make first oh and then</p>



<p class="wp-block-paragraph">notice how it mmm what happened oh what did I do wrong well I did something wrong</p>



<p class="wp-block-paragraph">okay hang on let me see if I can fix that first oh what in the heck did I do</p>



<p class="wp-block-paragraph">second and third. Okay, so I didn&#8217;t break anything.</p>



<p class="wp-block-paragraph">First.o. Oh, because when I typed this on the command line, I was typing first.o and</p>



<p class="wp-block-paragraph">well, that&#8217;s not the target anymore. The real target now is underscore build first.o.</p>



<p class="wp-block-paragraph">So maybe this is a good time to stick our binary target inside of there.</p>



<p class="wp-block-paragraph">So we have the binary target. I kind of ignored it for a second because I wanted to show you an object file first.</p>



<p class="wp-block-paragraph">We want to make the main file that gets executed.</p>



<p class="wp-block-paragraph">We have to link everything together.</p>



<p class="wp-block-paragraph">So, well, maybe this is a better description down here for that.</p>



<p class="wp-block-paragraph">And then up here, I&#8217;ll say alias for just building the binary.</p>



<p class="wp-block-paragraph">Whoops.</p>



<p class="wp-block-paragraph">Binary building.</p>



<p class="wp-block-paragraph">Building.</p>



<p class="wp-block-paragraph">There we go.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So now we&#8217;re actually going to do it.</p>



<p class="wp-block-paragraph">So we&#8217;ll put bin.</p>



<p class="wp-block-paragraph">So now bin is its own target, meaning our main program that we want to create</p>



<p class="wp-block-paragraph">main program that we want to create is uh it&#8217;s going to happen somehow the uh dependencies that</p>



<p class="wp-block-paragraph">it needs though should be all of our object files that we intend to create so first you know one of</p>



<p class="wp-block-paragraph">its dependencies should be uh inside of the builder and i know this is annoying to type these variables</p>



<p class="wp-block-paragraph">all over the place but kind of the price you pay for having everything outside of the working</p>



<p class="wp-block-paragraph">directory but i guess that&#8217;s why a lot of people don&#8217;t do this we say builder first dot o so</p>



<p class="wp-block-paragraph">So basically saying before we can create the executable, we have to first build the first</p>



<p class="wp-block-paragraph">object file.</p>



<p class="wp-block-paragraph">And then we&#8217;ll just name more dependencies.</p>



<p class="wp-block-paragraph">I&#8217;ll say the builder, we separate dependencies using spaces.</p>



<p class="wp-block-paragraph">That&#8217;s another reason that make has problems with spaces if you&#8217;re going to do like an</p>



<p class="wp-block-paragraph">absolute path or something.</p>



<p class="wp-block-paragraph">So then we&#8217;re going to grab the second object file as a dependency and then the third object</p>



<p class="wp-block-paragraph">file as a dependency.</p>



<p class="wp-block-paragraph">means we just need to set up targets for each one of those object files we only have first.o</p>



<p class="wp-block-paragraph">set up so far we&#8217;ll have to set up the second and the third one so aside from those dependencies we</p>



<p class="wp-block-paragraph">want to make sure that the builder is actually created so we&#8217;ll put builder as another uh you</p>



<p class="wp-block-paragraph">know non-time stamped uh dependency like we did with the object file then the command we&#8217;ll actually</p>



<p class="wp-block-paragraph">and remember CPP is just GCC and then the link flags is the stuff that we set up up above</p>



<p class="wp-block-paragraph">which is basically going to be you know wall pedantic G and then M64 no pi no you know all</p>



<p class="wp-block-paragraph">the stuff we don&#8217;t want to type manually at the very bottom so we&#8217;re going to do that link flags</p>



<p class="wp-block-paragraph">you know we want to give it every single object file as an input so we&#8217;ll name you know first.o</p>



<p class="wp-block-paragraph">and then we&#8217;ll name second.o second.o and you know i&#8217;m getting irritated i hope you can tell</p>



<p class="wp-block-paragraph">already i don&#8217;t want to type all these things so we can use a shell trick we can put a wild card</p>



<p class="wp-block-paragraph">there we can say how about i just give you every file asterisk that ends in.o so star.o basically</p>



<p class="wp-block-paragraph">on that command line it&#8217;s going to go look into the build directory and just</p>



<p class="wp-block-paragraph">give it every object file that it sees it&#8217;s not a great idea if you have</p>



<p class="wp-block-paragraph">multiple different executables that you want to make and they&#8217;ve all got their</p>



<p class="wp-block-paragraph">own main functions and they&#8217;re all in the same builder but in our case we only</p>



<p class="wp-block-paragraph">have one executable with one main function so we can just throw all of the</p>



<p class="wp-block-paragraph">object files we want at it if you had other types of object files you wanted</p>



<p class="wp-block-paragraph">to link into your executable like for example shared object files you could</p>



<p class="wp-block-paragraph">object files you could basically do the same thing but just go you know builder star star.so</p>



<p class="wp-block-paragraph">or maybe not even in the builder if i if let&#8217;s say if i gave you a shared object file</p>



<p class="wp-block-paragraph">and i wanted you to link that into your program you would just specify wherever it was</p>



<p class="wp-block-paragraph">you know maybe it&#8217;s in the root something.so maybe it&#8217;s in a different folder um and maybe</p>



<p class="wp-block-paragraph">you want to create a variable up top to just kind of like name where the shared object files are</p>



<p class="wp-block-paragraph">libraries are it&#8217;s up to you but I&#8217;m just letting you know this is how you</p>



<p class="wp-block-paragraph">would do it to get a shared object file in there as well for this program it&#8217;s</p>



<p class="wp-block-paragraph">very simple we just are gonna grab the object files and that&#8217;s it so now we&#8217;re</p>



<p class="wp-block-paragraph">just ready to specify the output file with a dash o and we&#8217;ll use that same</p>



<p class="wp-block-paragraph">trick again dollar sign and at so we don&#8217;t have to specify the the full</p>



<p class="wp-block-paragraph">target which is just going to be the bin variable so let&#8217;s see what do I got to</p>



<p class="wp-block-paragraph">If we run it right now, it should fail because it&#8217;ll complain that we don&#8217;t have second and third built.</p>



<p class="wp-block-paragraph">But at least I have enough now to use the make run target.</p>



<p class="wp-block-paragraph">So we can stop specifying the names of files and just say something like make run or make build and it&#8217;s just way easier to type.</p>



<p class="wp-block-paragraph">So I&#8217;m going to type make run.</p>



<p class="wp-block-paragraph">It&#8217;s going to depend on build.</p>



<p class="wp-block-paragraph">Build is going to execute before run even tries to run.</p>



<p class="wp-block-paragraph">Build is going to say, well, I depend on the binary, the executable.</p>



<p class="wp-block-paragraph">Then that means the binary&#8217;s target is going to run.</p>



<p class="wp-block-paragraph">run it&#8217;s going to depend on all these object files so before it even tries to do anything</p>



<p class="wp-block-paragraph">it&#8217;s going to go down here to the first dot o object file it&#8217;s actually going to build it</p>



<p class="wp-block-paragraph">then it&#8217;s going to come back and try to handle the next dependency which is second dot o</p>



<p class="wp-block-paragraph">but there&#8217;s no target for second dot o and it&#8217;s not on disk um so it&#8217;s just going to fail at that</p>



<p class="wp-block-paragraph">point so let&#8217;s see if let&#8217;s see if i&#8217;m right we&#8217;re going to do make run clear and whoops</p>



<p class="wp-block-paragraph">Make run</p>



<p class="wp-block-paragraph">Okay, so ensuring the build directory. Oh, I forgot to mention that yet</p>



<p class="wp-block-paragraph">It&#8217;s gonna ensure the build directory then it actually builds the first object file so far so good</p>



<p class="wp-block-paragraph">Then it complains no rule to make the target second auto so we can&#8217;t continue Oh</p>



<p class="wp-block-paragraph">drat</p>



<p class="wp-block-paragraph">By the way just to show you I think it&#8217;s like a J</p>



<p class="wp-block-paragraph">Let&#8217;s say we wanted to launch this with eight threads. I think it might be low</p>



<p class="wp-block-paragraph">Is it lowercase or uppercase J? I can never remember. Let me try lowercase</p>



<p class="wp-block-paragraph">second how about uppercase nope okay so it&#8217;s lowercase well I guess it just fails right there</p>



<p class="wp-block-paragraph">I was kind of hoping it would try to spawn off two threads to look at second and also third</p>



<p class="wp-block-paragraph">at the same time and then fail twice maybe that&#8217;s why it didn&#8217;t do that because it automatically</p>



<p class="wp-block-paragraph">saw right away oh we can&#8217;t do anything so let&#8217;s just cut the whole build process so now I&#8217;m going</p>



<p class="wp-block-paragraph">Cut cut cut paste paste and then I&#8217;m going to say build the second object file</p>



<p class="wp-block-paragraph">So we&#8217;re going to depend on seconds</p>



<p class="wp-block-paragraph">There are actually advanced patterns you can use so that you don&#8217;t even have to specify the object files you can</p>



<p class="wp-block-paragraph">There&#8217;s there&#8217;s these things that people do I did it a couple times</p>



<p class="wp-block-paragraph">But I don&#8217;t really like it where you can have make sort of scan your source code directory for all CPP files and</p>



<p class="wp-block-paragraph">Automatically compile them in the exact same way and then the output file is like</p>



<p class="wp-block-paragraph">And then the output file is like the name of the source code file and then.o concatenated at the end of it.</p>



<p class="wp-block-paragraph">But this video is not like that advanced, so I&#8217;m not going to do that.</p>



<p class="wp-block-paragraph">So we&#8217;re going to compile second.c into second.o.</p>



<p class="wp-block-paragraph">And we need to make sure the build directory is created.</p>



<p class="wp-block-paragraph">And instead of using the CPP compiler, we&#8217;re going to use the regular C compiler.</p>



<p class="wp-block-paragraph">And then we&#8217;re going to do cc flags right there.</p>



<p class="wp-block-paragraph">and I think that&#8217;s all we need so then we&#8217;re gonna do the last object file by</p>



<p class="wp-block-paragraph">the way in nano I&#8217;m going control K to cut and control you to paste and it&#8217;s</p>



<p class="wp-block-paragraph">kind of convenient if you want to like duplicate you know a few lines we&#8217;re</p>



<p class="wp-block-paragraph">gonna use the ASM to assemble the assembly code so I&#8217;m gonna do third dot</p>



<p class="wp-block-paragraph">what it was and then we have to use a totally different command now we have to use the assembly</p>



<p class="wp-block-paragraph">assembler variable so that&#8217;s the name of the tool that assembles and then we&#8217;ll give it the assembly</p>



<p class="wp-block-paragraph">flags i mean i guess it&#8217;s not that different and then we&#8217;ll say give it the first dependency which</p>



<p class="wp-block-paragraph">is just the source code and then output to the at target so we should have like a lot of stuff</p>



<p class="wp-block-paragraph">ready to go let&#8217;s see if this works now if i say clear and make run then what is it going to do it</p>



<p class="wp-block-paragraph">then what is it going to do it the first thing it does is it compiles the second object file</p>



<p class="wp-block-paragraph">notice how it did not compile the first object file because remember we just compiled that</p>



<p class="wp-block-paragraph">and we didn&#8217;t change the source code so it just ignored it and we have a faster compile</p>



<p class="wp-block-paragraph">then it assembles aka compiles the assembly to its own object file and then</p>



<p class="wp-block-paragraph">now that all those object files are satisfied notice how like you know for the binary</p>



<p class="wp-block-paragraph">all of those object files first and make sure the build directory is there. Then finally it can</p>



<p class="wp-block-paragraph">execute its own recipe, which is just one command saying, you know, let&#8217;s link this stuff together</p>



<p class="wp-block-paragraph">by grabbing all the object files. So that&#8217;s this line right here, the linking flags and the linker.</p>



<p class="wp-block-paragraph">So it&#8217;s like GCC and all the linking flags, the no pie and all that stuff. And it&#8217;s expanded that</p>



<p class="wp-block-paragraph">variable. Remember we put builder slash star dot O. So that glob right there basically says grab</p>



<p class="wp-block-paragraph">glob right there basically says grab all the object files from the build directory and then</p>



<p class="wp-block-paragraph">output the main program in the build directory no no i think even if you&#8217;re using a build directory</p>



<p class="wp-block-paragraph">sometimes people will still put their executable in the root i don&#8217;t know it&#8217;s up to you i don&#8217;t</p>



<p class="wp-block-paragraph">really care finally after all that is done you&#8217;ll see let&#8217;s see what we actually did is we said let&#8217;s</p>



<p class="wp-block-paragraph">its recipe it goes down here for build and then build says first we need to build that binary</p>



<p class="wp-block-paragraph">and then binaries like first we got to build the object files and then you know all those</p>



<p class="wp-block-paragraph">get built finally when the object files are built then the binary gets to link itself</p>



<p class="wp-block-paragraph">when it&#8217;s done linking itself then we go back to this point because now finally the dependencies</p>



<p class="wp-block-paragraph">on line 108 are satisfied then that means the build target its dependencies are satisfied</p>



<p class="wp-block-paragraph">dependencies are satisfied. It would execute its recipe, but there&#8217;s no recipe there. So it just</p>



<p class="wp-block-paragraph">goes back to run because in the first place, run said, I need you to make sure that build is handled</p>



<p class="wp-block-paragraph">before I&#8217;ll execute my recipe or all of my statements. So finally, after all that stuff</p>



<p class="wp-block-paragraph">was done, then it&#8217;s just a command line that just names the executable, which is going to run it.</p>



<p class="wp-block-paragraph">And that&#8217;s this last part right here. So right there, it just names the executable using a</p>



<p class="wp-block-paragraph">using a whoops using a relative path to our main executable so now below that</p>



<p class="wp-block-paragraph">line the program is actually running it&#8217;s like hello from first hello from</p>



<p class="wp-block-paragraph">second hello from third and watch this if I do make run again nothing happens</p>



<p class="wp-block-paragraph">except executing the program notice how none of the object files are getting</p>



<p class="wp-block-paragraph">built the binary is not getting linked nothing is happening because it&#8217;s</p>



<p class="wp-block-paragraph">already done all it does for the run target now is just run the executable</p>



<p class="wp-block-paragraph">run the executable. It&#8217;s the same thing as if we did build main, just to run it. That&#8217;s it.</p>



<p class="wp-block-paragraph">You know, of course, it&#8217;s a little more proper to go dot slash, right? You don&#8217;t have to use the</p>



<p class="wp-block-paragraph">dot if the thing you&#8217;re naming is in a different directory, but you do if it&#8217;s in the same directory.</p>



<p class="wp-block-paragraph">Like if we just went into the build directory, by the way, here&#8217;s all our build files. They&#8217;re</p>



<p class="wp-block-paragraph">in one convenient place. You can do a git ignore on that, or you can just delete the folder if</p>



<p class="wp-block-paragraph">if you want to clean everything.</p>



<p class="wp-block-paragraph">But we can&#8217;t just type main here, it&#8217;s not going to work.</p>



<p class="wp-block-paragraph">We have to do a dot slash main because we&#8217;re in the same folder.</p>



<p class="wp-block-paragraph">But if we&#8217;re one level higher, then we can just name build main and it&#8217;ll work.</p>



<p class="wp-block-paragraph">Okay, so let&#8217;s do another thing real fast here.</p>



<p class="wp-block-paragraph">Let&#8217;s do another target that is kind of typical.</p>



<p class="wp-block-paragraph">It is the clean target.</p>



<p class="wp-block-paragraph">useful when people have object files just scattered around the root of their of their file system</p>



<p class="wp-block-paragraph">there their repository but i like to add it in anyway for mine even though mine&#8217;s a little bit</p>



<p class="wp-block-paragraph">cleaner right now so we&#8217;ll do another target called clean and we&#8217;ll just say clean the uh the</p>



<p class="wp-block-paragraph">build area system thing stuff and i&#8217;m just going to put the word clean with a colon no dependencies</p>



<p class="wp-block-paragraph">meaning it&#8217;ll always run right away and not depend on anything it&#8217;s obviously a phony target because</p>



<p class="wp-block-paragraph">It&#8217;s obviously a phony target because I&#8217;m not going to make a file called clean so I&#8217;m</p>



<p class="wp-block-paragraph">going to stick that as a dependency to phony.</p>



<p class="wp-block-paragraph">And then what is it going to do?</p>



<p class="wp-block-paragraph">Usually this is where you put something like let&#8217;s remove star dot o, let&#8217;s remove all</p>



<p class="wp-block-paragraph">of the object files and then let&#8217;s remove the binary file and let&#8217;s remove anything</p>



<p class="wp-block-paragraph">that we built so that we can just clean it.</p>



<p class="wp-block-paragraph">Maybe I could put that here, build dir slash o, I&#8217;m going to make it a little bit better</p>



<p class="wp-block-paragraph">in a second.</p>



<p class="wp-block-paragraph">inside of the builder and then we&#8217;ll also remove the binary.</p>



<p class="wp-block-paragraph">So when we go back into our file system,</p>



<p class="wp-block-paragraph">if we list the build directory,</p>



<p class="wp-block-paragraph">we should see that it&#8217;s empty after we run this.</p>



<p class="wp-block-paragraph">So I&#8217;m going to do that right now.</p>



<p class="wp-block-paragraph">I&#8217;m going to do make clean.</p>



<p class="wp-block-paragraph">And then you can see that these two removal commands got executed.</p>



<p class="wp-block-paragraph">And then if I list the directory again, notice how it&#8217;s empty.</p>



<p class="wp-block-paragraph">But the remove command will fail</p>



<p class="wp-block-paragraph">if it tries to remove something that doesn&#8217;t exist.</p>



<p class="wp-block-paragraph">to remove something that doesn&#8217;t exist so we&#8217;ll actually get like a a nasty message from clean</p>



<p class="wp-block-paragraph">or from make if we try to clean again so we say make clean it says remove tried to remove object</p>



<p class="wp-block-paragraph">files but there was nothing inside of there no such file or directory so then it just stops the</p>



<p class="wp-block-paragraph">whole process well that seems okay for now but what if you uh what if you had gone in and removed or</p>



<p class="wp-block-paragraph">and that stopped other things from being cleaned you&#8217;d probably end up being</p>



<p class="wp-block-paragraph">pretty frustrated right so for the clean target I&#8217;m just gonna say remove is a</p>



<p class="wp-block-paragraph">command that won&#8217;t stop the build or the target so I&#8217;m gonna put a minus in</p>



<p class="wp-block-paragraph">front of there meaning don&#8217;t stop if something goes wrong just keep</p>



<p class="wp-block-paragraph">executing all these commands and so now if we do clear and make clean notice how</p>



<p class="wp-block-paragraph">it actually tries to remove both types of things it doesn&#8217;t just stop on the</p>



<p class="wp-block-paragraph">I guess this is the first problem.</p>



<p class="wp-block-paragraph">It&#8217;s trying to remove the object files.</p>



<p class="wp-block-paragraph">Then remove says, no, I can&#8217;t do that.</p>



<p class="wp-block-paragraph">There&#8217;s nothing there.</p>



<p class="wp-block-paragraph">And then make says, I&#8217;m ignoring you.</p>



<p class="wp-block-paragraph">Stop whining.</p>



<p class="wp-block-paragraph">There is no bathroom.</p>



<p class="wp-block-paragraph">And then the same thing happens for removing the executable main.</p>



<p class="wp-block-paragraph">But we can make this actually a little bit more efficient.</p>



<p class="wp-block-paragraph">I mean, this is kind of what you&#8217;ll do if everything is sitting at the root of your repo.</p>



<p class="wp-block-paragraph">But if we simply have a build directory and you&#8217;re absolutely sure that you already have</p>



<p class="wp-block-paragraph">you know set to the correct value then you could just remove i don&#8217;t know if i want to do it now</p>



<p class="wp-block-paragraph">because i&#8217;m getting scared you could just remove the entire build directory i&#8217;m going to do it but</p>



<p class="wp-block-paragraph">i&#8217;ll explain to you why i kind of don&#8217;t want to do it in a second we could remove the entire build</p>



<p class="wp-block-paragraph">directory so like with the remove command remove recursively the entire build directory</p>



<p class="wp-block-paragraph">just so you don&#8217;t see it if you feel like it&#8217;s an eyesore so i&#8217;m going to do make clean</p>



<p class="wp-block-paragraph">do it again do it again do it again and notice well why wasn&#8217;t it</p>



<p class="wp-block-paragraph">i feel like it should have failed but i guess remove felt like it wasn&#8217;t a failure if build</p>



<p class="wp-block-paragraph">didn&#8217;t exist but notice how the builder is gone so i didn&#8217;t really have to specify</p>



<p class="wp-block-paragraph">the object files but it&#8217;s a little bit safer i don&#8217;t know it depends on your philosophy</p>



<p class="wp-block-paragraph">this is way more compact and nicer that was my first feeling but it&#8217;s also a little more</p>



<p class="wp-block-paragraph">there into the variables area and i like change the builder somehow i change its name or i change</p>



<p class="wp-block-paragraph">its value and i accidentally now have this variable pointed to like a dangerous path</p>



<p class="wp-block-paragraph">and then if i type make clean it just erases everything not sure i really like that idea so</p>



<p class="wp-block-paragraph">i&#8217;m going to do i&#8217;m going to go back to the original way which takes more typing</p>



<p class="wp-block-paragraph">remove every object file and maybe before that let&#8217;s remove the binary so if we do</p>



<p class="wp-block-paragraph">if we do make build which by the way will only build things it won&#8217;t run anything remember</p>



<p class="wp-block-paragraph">the dependency graph that we looked at a little while ago or not the dependency graph that we</p>



<p class="wp-block-paragraph">explained the dependencies so it does everything required to build but it doesn&#8217;t actually run the</p>



<p class="wp-block-paragraph">program and that&#8217;s fine i just wanted to go look inside of the build directory</p>



<p class="wp-block-paragraph">and you can see it&#8217;s got all the stuff there so then if i just run make clean one more time</p>



<p class="wp-block-paragraph">by the way, if I try to run make clean from here,</p>



<p class="wp-block-paragraph">there&#8217;s no make file in this directory.</p>



<p class="wp-block-paragraph">So nothing&#8217;s going to happen.</p>



<p class="wp-block-paragraph">So I&#8217;m going to go up one level, make clean.</p>



<p class="wp-block-paragraph">And then if I list the build directory,</p>



<p class="wp-block-paragraph">there&#8217;s just nothing inside of it.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">All right.</p>



<p class="wp-block-paragraph">Let me just look at my notes right here.</p>



<p class="wp-block-paragraph">I just finished building this whole giant make file.</p>



<p class="wp-block-paragraph">It&#8217;s not even like that complicated,</p>



<p class="wp-block-paragraph">but I hope that you&#8217;ve learned a lot</p>



<p class="wp-block-paragraph">about making make files at this point.</p>



<p class="wp-block-paragraph">this point i hope you kind of like the idea let me just double check there&#8217;s nothing else i wanted</p>



<p class="wp-block-paragraph">to say for this video oh i should point out that gnu make is not the only build system available</p>



<p class="wp-block-paragraph">it&#8217;s just the one that i like the most um remember you can also put shortcuts in there like any</p>



<p class="wp-block-paragraph">command line that you could actually type could be part of the recipe of a target it doesn&#8217;t have</p>



<p class="wp-block-paragraph">to only build it doesn&#8217;t have to only be build targets so again you could make commands in there</p>



<p class="wp-block-paragraph">like deploy your executable somewhere or check something or like a long time ago I used to have</p>



<p class="wp-block-paragraph">a recipe actually it was that program I was talking about at the beginning where I converted</p>



<p class="wp-block-paragraph">an hour-long compilation to just like a minute I had another target in there called deploy so I&#8217;d</p>



<p class="wp-block-paragraph">say make deploy and what it would do is it would build and if it built then it would run unit tests</p>



<p class="wp-block-paragraph">on my code and if those succeeded then it would copy my source code to one of my other servers</p>



<p class="wp-block-paragraph">my other servers then remotely it would tell that other server to build and run tests and if all</p>



<p class="wp-block-paragraph">that succeeded you know if it didn&#8217;t succeed then it would just quit if all that succeeded then it</p>



<p class="wp-block-paragraph">would shut down the the server that I had written as a running service and then it would copy the</p>



<p class="wp-block-paragraph">freshly built executable to the right location and then it would restart the service so basically I</p>



<p class="wp-block-paragraph">just like do a bunch of coding and then I you know run my test if everything seems cool then I go make</p>



<p class="wp-block-paragraph">five minutes or whatever it took to run all the tests and do another compile and deploy everything</p>



<p class="wp-block-paragraph">and my server was just totally updated just by that so there&#8217;s a lot of stuff you can do but</p>



<p class="wp-block-paragraph">there are other great build systems out there there&#8217;s one called gradle there&#8217;s one called</p>



<p class="wp-block-paragraph">maven there&#8217;s other like node.js systems there&#8217;s a ton of build systems out there</p>



<p class="wp-block-paragraph">probably a slightly more popular popular c++ build system is called cmake it&#8217;s more tailored to c++</p>



<p class="wp-block-paragraph">um but you know you obviously don&#8217;t need to do it it&#8217;s just i think like a little bit easier</p>



<p class="wp-block-paragraph">depending on what you want to do so keep that in mind this is not the only system there&#8217;s a lot</p>



<p class="wp-block-paragraph">out there to explore but this is this is definitely a great first step um let&#8217;s see what else can i do</p>



<p class="wp-block-paragraph">oh we showed you the diagram showed you the info function and the targets and the dependencies</p>



<p class="wp-block-paragraph">and the run build well i guess i&#8217;m out of stuff to show you that&#8217;s that&#8217;s all i had written down</p>



<p class="wp-block-paragraph">that I wanted to show you maybe I could this is not a git video I&#8217;ll make you</p>



<p class="wp-block-paragraph">know I have other videos forget but you know if this is a git repository you</p>



<p class="wp-block-paragraph">would nano git ignore just because I kept mentioning this we&#8217;ll do nano git</p>



<p class="wp-block-paragraph">ignore and then I&#8217;ll just say ignore the build directory and ignore swap files so</p>



<p class="wp-block-paragraph">I&#8217;ll say like ignore the build directory and ignore anything that&#8217;s edited and</p>



<p class="wp-block-paragraph">your git status and git add and git commit and stuff then the build directory wouldn&#8217;t even show</p>



<p class="wp-block-paragraph">up so yeah kind of i guess it&#8217;s kind of unnecessary for this project okay i think that concludes this</p>



<p class="wp-block-paragraph">video assuming i was actually recording this entire time thank you so much for watching i</p>



<p class="wp-block-paragraph">hope you learned a little bit of stuff and had a little bit of fun i&#8217;ll see you in the next video</p>



<p class="wp-block-paragraph">practice practice practice and start making your own make file videos and let me know</p>



<p class="wp-block-paragraph">files in your own programs and let me know if you liked the content of this video and like if it</p>



<p class="wp-block-paragraph">helped you i love receiving emails way after the fact when people say hey i love make files now</p>



<p class="wp-block-paragraph">and it&#8217;s all because of you and i do it all the time because then i get to sit alone in my dark</p>



<p class="wp-block-paragraph">room and giggle to myself it&#8217;s all because of me um okay i think that&#8217;s probably a good note to</p>



<p class="wp-block-paragraph">hey everybody thanks for watching this video again from the bottom of my heart I really</p>



<p class="wp-block-paragraph">appreciate it I do hope you did learn something and have some fun if you could do me a please a</p>



<p class="wp-block-paragraph">small little favor could you please subscribe and follow this channel or these videos or whatever it</p>



<p class="wp-block-paragraph">is you do on the current social media website that you&#8217;re looking at right now it would really mean</p>



<p class="wp-block-paragraph">the world to me and it&#8217;ll help make more videos and grow this community so we&#8217;ll be able to do</p>



<p class="wp-block-paragraph">videos, longer videos, better videos, or just I&#8217;ll be able to keep making videos in general. So please</p>



<p class="wp-block-paragraph">do me a kindness and subscribe. You know, sometimes I&#8217;m sleeping in the middle of the night</p>



<p class="wp-block-paragraph">and I just wake up because I know somebody subscribed or followed. It just wakes me up</p>



<p class="wp-block-paragraph">and I get filled with joy. That&#8217;s exactly what happens every single time. So you could do it as</p>



<p class="wp-block-paragraph">a nice favor to me or you could you could troll me if you want to just wake me up in the middle</p>



<p class="wp-block-paragraph">of the night, just subscribe and then I&#8217;ll just wake up. I promise that&#8217;s what will happen.</p>



<p class="wp-block-paragraph">Also, if you look at the middle of the screen right now, you should see a QR code which you can scan in order to go to the website</p>



<p class="wp-block-paragraph">which I think is also named somewhere at the bottom of this video and</p>



<p class="wp-block-paragraph">It&#8217;ll take you to my main website where you can just kind of like see all the videos</p>



<p class="wp-block-paragraph">I published and the services and tutorials and things that I offer and all that good stuff and</p>



<p class="wp-block-paragraph">If you have a suggestion for</p>



<p class="wp-block-paragraph">Clarifications or errata or just future videos that you want to see</p>



<p class="wp-block-paragraph">please leave a comment or if you just want to say hey what&#8217;s up what&#8217;s going on you know just send</p>



<p class="wp-block-paragraph">me a comment whatever i also wake up for those in the middle of the night i get i wake up in a cold</p>



<p class="wp-block-paragraph">sweat and i&#8217;m like it would really it really mean the world to me i would really appreciate it so</p>



<p class="wp-block-paragraph">again thank you so much for watching this video and um enjoy the cool music</p>



<p class="wp-block-paragraph">as as i fade into the darkness which is coming for us all</p>



<p class="wp-block-paragraph">Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/master-gnu-makefiles-streamline-coding-builds-with-c-c-assembly/">Master GNU Makefiles: Streamline Coding Builds with C++, C &amp; Assembly</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/master-gnu-makefiles-streamline-coding-builds-with-c-c-assembly/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Hex to Decimal Made Easy: Fun &#038; Simple Conversion Guide!</title>
		<link>https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/</link>
					<comments>https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Fri, 02 May 2025 09:23:46 +0000</pubDate>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Conversions]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[beginner coding]]></category>
		<category><![CDATA[binary to decimal]]></category>
		<category><![CDATA[coding for beginners]]></category>
		<category><![CDATA[coding guide]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[computer science tutorial]]></category>
		<category><![CDATA[hex to decimal]]></category>
		<category><![CDATA[hexadecimal to decimal]]></category>
		<category><![CDATA[hexadecimal tutorial]]></category>
		<category><![CDATA[learn to code]]></category>
		<category><![CDATA[number conversion]]></category>
		<category><![CDATA[number systems]]></category>
		<category><![CDATA[programming tutorial]]></category>
		<category><![CDATA[tech education]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=95</guid>

					<description><![CDATA[<p>Learn to convert hexadecimal to decimal with this fun, easy guide! Perfect for beginners in coding and computer science. #HexToDecimal #LearnToCode</p>
<p>The post <a href="https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/">Hex to Decimal Made Easy: Fun &amp; Simple Conversion Guide!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Hex to Decimal Made Easy: Fun &amp; Simple Conversion Guide!" width="1380" height="776" src="https://www.youtube.com/embed/yDk-fB52i0A?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">Confused by hexadecimal numbers? Don’t worry! This fun, step-by-step guide makes converting hex to decimal super easy, even for beginners. With clear examples and a chill vibe, you’ll master this computer science skill in no time. Perfect for students, coders, or anyone curious about number systems. Hit subscribe for more coding tutorials, and check out our site for extra resources! #HexToDecimal #CodingForBeginners #ComputerScience #LearnToCode</p>



<p class="wp-block-paragraph">Introduction to Hexadecimal Conversion 00:00:00<br>Purpose of Conversion 00:00:11<br>Number System Basics 00:00:39<br>Hexadecimal Explanation 00:01:12<br>Converting Hex to Decimal 00:01:59<br>First Example Setup 00:02:35<br>Decimal Place Value Recap 00:03:02<br>Hexadecimal Place Value 00:05:14<br>Formula for Conversion 00:05:43<br>Translating Hex Letters 00:08:17<br>First Example Calculation 00:09:51<br>Second Example Introduction 00:11:14<br>Second Example Conversion 00:11:58<br>Second Example Result 00:13:11<br>Conclusion and Call to Action 00:14:00</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p class="wp-block-paragraph">Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hello there. Let&#8217;s talk about converting hexadecimal to decimal.</p>



<p class="wp-block-paragraph">So why would you do this? Of course, sometimes in computer science and other realms, you may be</p>



<p class="wp-block-paragraph">faced with a number that looks like this, and it&#8217;s got some letters in there, and it&#8217;s weird,</p>



<p class="wp-block-paragraph">and you&#8217;re thinking, oops, not a V. That wouldn&#8217;t work. Not a G. And you&#8217;re thinking like, what does</p>



<p class="wp-block-paragraph">what does this number mean in decimal well this is a number that is real and we can just change</p>



<p class="wp-block-paragraph">the way it&#8217;s represented uh to decimal so that we can understand what it is so just like a quick</p>



<p class="wp-block-paragraph">recap if you haven&#8217;t watched my other videos yet uh in decimal we have a base 10 system which just</p>



<p class="wp-block-paragraph">basically means we have these characters zero one two three four five six seven eight nine there</p>



<p class="wp-block-paragraph">base is 10. In binary, of course, we have base two, which is just, you know, we have a zero and a one</p>



<p class="wp-block-paragraph">because in the computer, which is why we learn binary, we just have on and off basically for</p>



<p class="wp-block-paragraph">every single, you know, part of the computer. There&#8217;s just like a certain voltage or there&#8217;s</p>



<p class="wp-block-paragraph">not a certain voltage and that&#8217;s it. And then for hexadecimal, which is a way to represent the same</p>



<p class="wp-block-paragraph">numbers, but just in a more compact way. It&#8217;s a little bit more compact than decimal. It&#8217;s a lot</p>



<p class="wp-block-paragraph">than binary we can say that this is base 16 which means we have 16 total characters that we can work</p>



<p class="wp-block-paragraph">with zero one two three four five six seven eight nine and once we run out of numbers we just start</p>



<p class="wp-block-paragraph">using letters so a b c d e f so there are 16 total characters if we include the zero which means we</p>



<p class="wp-block-paragraph">So that&#8217;s the basics of you know the number basis let&#8217;s uh let&#8217;s work out how to convert a hex</p>



<p class="wp-block-paragraph">number to decimal. So I&#8217;m going to say ox because in hex when you write down a hex number you should</p>



<p class="wp-block-paragraph">usually put ox in front of it unless the program you&#8217;re working with doesn&#8217;t understand that but</p>



<p class="wp-block-paragraph">usually especially for a human reader you should do it this way. So I&#8217;m going to just type like a</p>



<p class="wp-block-paragraph">few random maybe I have to I have to keep the number small because hex will explode it&#8217;ll be</p>



<p class="wp-block-paragraph">not careful. So I&#8217;m going to put like a I don&#8217;t know, maybe a few decimal numbers there or a few</p>



<p class="wp-block-paragraph">like digits that are zero to nine, then I&#8217;ll just to make it more interesting, I&#8217;ll put some letters</p>



<p class="wp-block-paragraph">in there. How about like an E there? And then I don&#8217;t know, like, we&#8217;ll do a B there. Okay, so</p>



<p class="wp-block-paragraph">how many do I have? 12341234? How about we get rid of? Now, let&#8217;s go for it. This is going to be an</p>



<p class="wp-block-paragraph">So this is our starting number hexadecimal. What we need to do is understand that, well,</p>



<p class="wp-block-paragraph">a recap if you haven&#8217;t watched my other videos yet. In decimal we have, let&#8217;s say, 0, 1, 2, 3,</p>



<p class="wp-block-paragraph">4, 5, 6. You know that the first digit has a strength of 1. You multiply 6 by 1 to understand</p>



<p class="wp-block-paragraph">the real power of that 6. For the 5, you know that it has a power of 10 or a strength of 10</p>



<p class="wp-block-paragraph">10 because it&#8217;s the next digit over you know to the left same thing for the four it&#8217;s like got a</p>



<p class="wp-block-paragraph">strength of 100 and so every time you move to the left the strength of the digit increases by a</p>



<p class="wp-block-paragraph">factor of 10. why does it increase by a factor of 10 because decimal is base 10 because we have 10</p>



<p class="wp-block-paragraph">possible digits we can represent for each character okay so by the time we get to that</p>



<p class="wp-block-paragraph">left, we have a strength of 100,000. So, you know, if you wanted to really understand 100,000,</p>



<p class="wp-block-paragraph">if you really wanted to understand, you know, how powerful, let me, let me give some spacing here.</p>



<p class="wp-block-paragraph">So this feels better. Okay. If you really wanted to understand like, you know, what is the strength?</p>



<p class="wp-block-paragraph">What is like the actual value of this digit right here? You&#8217;re imagining this is like 100,000.</p>



<p class="wp-block-paragraph">this digit here you&#8217;re imagining that this is two of ten thousand you know two times ten thousand</p>



<p class="wp-block-paragraph">and so forth so uh uh just like another recap the first digit is really 10 to the zero power</p>



<p class="wp-block-paragraph">like in terms of the strength because if you multiply um let me pin this to the top</p>



<p class="wp-block-paragraph">if you multiply you know 10 to the something power and you start at zero with the most</p>



<p class="wp-block-paragraph">the weakest digit 10 to the zero power gives a strength of one and then every time you move over</p>



<p class="wp-block-paragraph">to the left you just increase the exponent there by one so 10 to the first power is going to be 10</p>



<p class="wp-block-paragraph">that&#8217;s what that five has got so it&#8217;ll be five times 10 to give us an understanding of how you</p>



<p class="wp-block-paragraph">know powerful that digit is move one over to the left it&#8217;s 10 to the second power so that&#8217;s 100</p>



<p class="wp-block-paragraph">move one over to the left it&#8217;s 10 to the third power and so forth until we get to 10 to the fifth</p>



<p class="wp-block-paragraph">1 times 10 to the fifth power to understand how powerful that is so we can do the same exact thing</p>



<p class="wp-block-paragraph">with hexadecimal except instead of raising 10 to a power we raise 16 to a power because hexadecimal</p>



<p class="wp-block-paragraph">is base 16 whereas decimal is base 10. so that means this e is is uh you know 10 to the or sorry</p>



<p class="wp-block-paragraph">16 to the zero power and then that 3 is 16 to the 1 power and that f is 16 to the 2 power and so</p>



<p class="wp-block-paragraph">16 to the 2 power and so forth so first what we should do is let&#8217;s write out a</p>



<p class="wp-block-paragraph">formula which won&#8217;t work in a calculator because we&#8217;re going to put some letters</p>



<p class="wp-block-paragraph">in there and then later we&#8217;ll translate the letters to actual values so we&#8217;ll</p>



<p class="wp-block-paragraph">start off with the e we&#8217;ll say e times 16 to the something power it&#8217;s going to be</p>



<p class="wp-block-paragraph">16 to the zero power okay so then the next digit is 3 so 3 times 16 to the</p>



<p class="wp-block-paragraph">And then the next thing is going to be F times 16 to the second power.</p>



<p class="wp-block-paragraph">And just as a reminder here, I&#8217;m starting with zero with the smallest digit.</p>



<p class="wp-block-paragraph">And I&#8217;m just working my way up in steps of one.</p>



<p class="wp-block-paragraph">So it&#8217;s zero power or raised to zero and raised to one and raised to two and just so forth all the way to the left.</p>



<p class="wp-block-paragraph">That number will just keep increasing by one.</p>



<p class="wp-block-paragraph">The exponent will increase by one.</p>



<p class="wp-block-paragraph">times 16 to the third power do it again um one times 16 to the fourth power do it again</p>



<p class="wp-block-paragraph">um d times 16 to the fourth power oh what did i do did i erase something</p>



<p class="wp-block-paragraph">0, 1, 2, 3, 4, 5.</p>



<p class="wp-block-paragraph">Oh, that was supposed to be a 5.</p>



<p class="wp-block-paragraph">Okay, maybe it&#8217;s good that I thought I made a mistake</p>



<p class="wp-block-paragraph">because that drew my attention to the bad exponent.</p>



<p class="wp-block-paragraph">Okay, so after the D is a B.</p>



<p class="wp-block-paragraph">B times 16 to the 6th power.</p>



<p class="wp-block-paragraph">And then one more.</p>



<p class="wp-block-paragraph">We&#8217;ll say 6 times 16 to the 7th power.</p>



<p class="wp-block-paragraph">And then another one.</p>



<p class="wp-block-paragraph">A times 16 to the, whoops, to the eighth power.</p>



<p class="wp-block-paragraph">And another one.</p>



<p class="wp-block-paragraph">One times 16 to the ninth power.</p>



<p class="wp-block-paragraph">Ninth power.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So just double check your work real fast.</p>



<p class="wp-block-paragraph">You know, because I make typos all the time and I get things wrong all the time.</p>



<p class="wp-block-paragraph">So just double check.</p>



<p class="wp-block-paragraph">Zero, one, two, three, four, five, six, seven, eight, nine.</p>



<p class="wp-block-paragraph">It&#8217;s sequential.</p>



<p class="wp-block-paragraph">Double check the digits.</p>



<p class="wp-block-paragraph">6 b d 1 3 f 3 e okay so i got that right i&#8217;m not going to erase my work because if i end up screwing</p>



<p class="wp-block-paragraph">up the next part oh man is it going to be a hassle to correct so i&#8217;m just going to copy paste it here</p>



<p class="wp-block-paragraph">and then i&#8217;m going to start translating the letters to numbers anytime you see a number here like one</p>



<p class="wp-block-paragraph">time something it&#8217;s just one but every time you see a letter you have to translate that into</p>



<p class="wp-block-paragraph">in decimal. Remember in hex, we&#8217;ll say, what can I do?</p>



<p class="wp-block-paragraph">I can say A, B, C, D, E, F.</p>



<p class="wp-block-paragraph">And I can say that the A is worth 10.</p>



<p class="wp-block-paragraph">The B is worth 11.</p>



<p class="wp-block-paragraph">The C is worth 12.</p>



<p class="wp-block-paragraph">And the D is worth 13.</p>



<p class="wp-block-paragraph">The E is worth 14 and the F is worth 15.</p>



<p class="wp-block-paragraph">Well, maybe I should do the other numbers too.</p>



<p class="wp-block-paragraph">five, six, seven, eight, nine,</p>



<p class="wp-block-paragraph">just so we have a visual reminder</p>



<p class="wp-block-paragraph">of like what we&#8217;re even looking at.</p>



<p class="wp-block-paragraph">And I won&#8217;t write down what the digits are worth</p>



<p class="wp-block-paragraph">because they&#8217;re worth themselves, right?</p>



<p class="wp-block-paragraph">So like zero through nine, it&#8217;s just worth zero through nine.</p>



<p class="wp-block-paragraph">So now that we have this little translation table up here,</p>



<p class="wp-block-paragraph">anytime we see a letter,</p>



<p class="wp-block-paragraph">we can just translate it very quickly to the decimal value.</p>



<p class="wp-block-paragraph">So A is worth 10, we&#8217;ll put a 10 there.</p>



<p class="wp-block-paragraph">Maybe I&#8217;ll add some spacing so that this continues to line up.</p>



<p class="wp-block-paragraph">I see a B here, so the B is gonna be worth 11,</p>



<p class="wp-block-paragraph">11 add another space so it lines up i&#8217;m running out of room but i&#8217;ll try the d is worth 13 add</p>



<p class="wp-block-paragraph">another space so it lines up and then the f is worth 15 add another space so it lines up the e</p>



<p class="wp-block-paragraph">is worth 14 so i&#8217;ll add another space so it lines up okay let me just double check my work here a b d</p>



<p class="wp-block-paragraph">So now I&#8217;ve got like a big formula that I wrote out.</p>



<p class="wp-block-paragraph">I can literally now, I mean, you can do this in your head if you&#8217;re like a crazy genius,</p>



<p class="wp-block-paragraph">but I&#8217;m just going to paste this into a calculator and hit enter.</p>



<p class="wp-block-paragraph">And this is the number that we had originally in hex.</p>



<p class="wp-block-paragraph">Maybe I&#8217;ll put commas here to make things more fun.</p>



<p class="wp-block-paragraph">I don&#8217;t know.</p>



<p class="wp-block-paragraph">You don&#8217;t really need to do that, but I&#8217;m going to.</p>



<p class="wp-block-paragraph">So for me, it&#8217;s easier to read.</p>



<p class="wp-block-paragraph">this is uh like 113 trillion 478 no wait that&#8217;s a million and that&#8217;s a bill okay so 113 mil a</p>



<p class="wp-block-paragraph">billion 478 million 25 022. let me punch up my personal calculator here to make sure that i&#8217;m</p>



<p class="wp-block-paragraph">getting this right i&#8217;m not going to show this on the screen because i&#8217;ve just got this up</p>



<p class="wp-block-paragraph">on my host machine bet you didn&#8217;t know i&#8217;m inside of vm right now surprised you didn&#8217;t know that</p>



<p class="wp-block-paragraph">decimal and the number is supposed to be 113478025022 okay so we did this right we now know how</p>



<p class="wp-block-paragraph">to convert from hexadecimal to decimal and it&#8217;s pretty awesome right okay let&#8217;s do another number</p>



<p class="wp-block-paragraph">one that is not quite as hard let&#8217;s see how many digits do we have here one two three i think we</p>



<p class="wp-block-paragraph">5, 6, 7, 8, 9, 10.</p>



<p class="wp-block-paragraph">Yeah, okay, we had 10.</p>



<p class="wp-block-paragraph">Let&#8217;s do a five-digit hex number.</p>



<p class="wp-block-paragraph">Okay, maybe I&#8217;ll copy…</p>



<p class="wp-block-paragraph">I&#8217;ll copy just this table at the top</p>



<p class="wp-block-paragraph">since you don&#8217;t need it anymore,</p>



<p class="wp-block-paragraph">but I&#8217;m going to need it to do my calculations.</p>



<p class="wp-block-paragraph">So we&#8217;ll do 1, 2, 3, 4, 5,</p>



<p class="wp-block-paragraph">and I&#8217;ll just start randomly changing</p>



<p class="wp-block-paragraph">some of these numbers.</p>



<p class="wp-block-paragraph">Like an 8 over here, and how about like a 2?</p>



<p class="wp-block-paragraph">So I&#8217;ve got five numbers.</p>



<p class="wp-block-paragraph">This is OX.</p>



<p class="wp-block-paragraph">I&#8217;m going to say this is a hexadecimal number.</p>



<p class="wp-block-paragraph">Kind of ambiguous if we tell the reader this is a hex number,</p>



<p class="wp-block-paragraph">but then we put OX.</p>



<p class="wp-block-paragraph">Kind of don&#8217;t really need to tell them that it&#8217;s hex</p>



<p class="wp-block-paragraph">because OX tells you it&#8217;s hex.</p>



<p class="wp-block-paragraph">It&#8217;s not even part of the value.</p>



<p class="wp-block-paragraph">So let&#8217;s get on with it.</p>



<p class="wp-block-paragraph">I&#8217;ll start by just doing 8 times 16 to the something power,</p>



<p class="wp-block-paragraph">which is going to be 0 for that first position.</p>



<p class="wp-block-paragraph">the power as we go to the left so it&#8217;s going to be 1 times 16 to the first power and then it&#8217;s</p>



<p class="wp-block-paragraph">going to be f times 16 to the second power and then it&#8217;s going to be 2 times 16 to the third</p>



<p class="wp-block-paragraph">power oh no my thoughts are wandering i think i&#8217;m getting bored of recording this video i&#8217;m starting</p>



<p class="wp-block-paragraph">to the fourth power but honestly why couldn&#8217;t they end up together so and</p>



<p class="wp-block-paragraph">then I think one two three four five okay so that&#8217;s five digits a to f one</p>



<p class="wp-block-paragraph">eight a to f one eight all right zero one two three four just to make sure</p>



<p class="wp-block-paragraph">that I got my exponents right copy paste it so I don&#8217;t have to repeat my work if</p>



<p class="wp-block-paragraph">I get something wrong I&#8217;m gonna translate the letters into numbers so a</p>



<p class="wp-block-paragraph">becomes 10 f becomes 15 and the other numbers are fine as is I can just copy</p>



<p class="wp-block-paragraph">fine as is I can just copy paste this whole thing stick it into a calculator and now I know that</p>



<p class="wp-block-paragraph">this number is actually 667 416 with a little comma in there don&#8217;t put commas if you are taking an</p>



<p class="wp-block-paragraph">exam somewhere if you&#8217;re watching my video to help with your exam because most most likely the exam</p>



<p class="wp-block-paragraph">that you&#8217;re taking will not accept a comma it&#8217;s not been pre-programmed for a comma I don&#8217;t know</p>



<p class="wp-block-paragraph">If you start typing numbers and a comma just shows up, then it probably was programmed for a comma.</p>



<p class="wp-block-paragraph">But don&#8217;t assume it might be a string match and not a numeric match.</p>



<p class="wp-block-paragraph">So be careful out there.</p>



<p class="wp-block-paragraph">Be careful.</p>



<p class="wp-block-paragraph">So 667-416.</p>



<p class="wp-block-paragraph">Let me punch this into my personal calculator just to make sure I got this right and I don&#8217;t have to issue an errata.</p>



<p class="wp-block-paragraph">667-416.</p>



<p class="wp-block-paragraph">All right.</p>



<p class="wp-block-paragraph">We&#8217;ve done it.</p>



<p class="wp-block-paragraph">We know how to convert hexadecimal numbers into decimal numbers.</p>



<p class="wp-block-paragraph">Thank you so much for watching this video. I hope you enjoyed it and had a little bit of fun and</p>



<p class="wp-block-paragraph">learned a little bit of stuff. I&#8217;ll see you in the next video. Hey everybody, thanks for watching</p>



<p class="wp-block-paragraph">this video again from the bottom of my heart. I really appreciate it. I do hope you did learn</p>



<p class="wp-block-paragraph">something and have some fun. If you could do me a please, a small little favor, could you please</p>



<p class="wp-block-paragraph">subscribe and follow this channel or these videos or whatever it is you do on the current social</p>



<p class="wp-block-paragraph">It would really mean the world to me and it&#8217;ll help make more videos and grow this community.</p>



<p class="wp-block-paragraph">So we&#8217;ll be able to do more videos, longer videos, better videos, or just I&#8217;ll be able to keep making videos in general.</p>



<p class="wp-block-paragraph">So please do me a kindness and subscribe.</p>



<p class="wp-block-paragraph">You know, sometimes I&#8217;m sleeping in the middle of the night and I just wake up because I know somebody subscribed or followed.</p>



<p class="wp-block-paragraph">It just wakes me up and I get filled with joy.</p>



<p class="wp-block-paragraph">That&#8217;s exactly what happens every single time.</p>



<p class="wp-block-paragraph">So you could do it as a nice favor to me or you could troll me if you want to just wake me up in the middle of the night.</p>



<p class="wp-block-paragraph">Just subscribe.</p>



<p class="wp-block-paragraph">just wake me up in the middle of the night just subscribe and then I&#8217;ll just</p>



<p class="wp-block-paragraph">wake up I promise that&#8217;s what will happen also if you look at the middle of</p>



<p class="wp-block-paragraph">the screen right now you should see a QR code which you can scan in order to go</p>



<p class="wp-block-paragraph">to the website which I think is also named somewhere at the bottom of this</p>



<p class="wp-block-paragraph">video and it&#8217;ll take you to my main website where you can just kind of like</p>



<p class="wp-block-paragraph">see all the videos I published and the services and tutorials and things that I</p>



<p class="wp-block-paragraph">for clarifications or errata or just future videos that you want to see please leave a comment or if</p>



<p class="wp-block-paragraph">you just want to say hey what&#8217;s up what&#8217;s going on you know just send me a comment whatever I also</p>



<p class="wp-block-paragraph">wake up for those in the middle of the night I get I wake up in a cold sweat and I&#8217;m like</p>



<p class="wp-block-paragraph">it would really it really mean the world to me I would really appreciate it so again thank you so</p>



<p class="wp-block-paragraph">much for watching this video and enjoy the cool music as as I fade into the darkness which is</p>



<p class="wp-block-paragraph">the darkness which is coming for us all.</p>



<p class="wp-block-paragraph">Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/">Hex to Decimal Made Easy: Fun &amp; Simple Conversion Guide!</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/hex-to-decimal-made-easy-fun-simple-conversion-guide/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Binary to Decimal Made Easy: Fun Crash Course for Beginners</title>
		<link>https://www.NeuralLantern.com/binary-to-decimal-made-easy-fun-crash-course-for-beginners/</link>
					<comments>https://www.NeuralLantern.com/binary-to-decimal-made-easy-fun-crash-course-for-beginners/#respond</comments>
		
		<dc:creator><![CDATA[mike]]></dc:creator>
		<pubDate>Sun, 06 Apr 2025 01:41:06 +0000</pubDate>
				<category><![CDATA[Videos]]></category>
		<category><![CDATA[base 2 explained]]></category>
		<category><![CDATA[beginner coding]]></category>
		<category><![CDATA[binary conversion]]></category>
		<category><![CDATA[binary for beginners]]></category>
		<category><![CDATA[binary math]]></category>
		<category><![CDATA[binary to decimal]]></category>
		<category><![CDATA[binary tricks]]></category>
		<category><![CDATA[binary tutorial]]></category>
		<category><![CDATA[coding 101]]></category>
		<category><![CDATA[computer science basics]]></category>
		<category><![CDATA[decimal to binary]]></category>
		<category><![CDATA[how to read binary]]></category>
		<category><![CDATA[learn binary]]></category>
		<category><![CDATA[number systems]]></category>
		<category><![CDATA[tech explained]]></category>
		<guid isPermaLink="false">https://www.NeuralLantern.com/?p=82</guid>

					<description><![CDATA[<p>Binary got you baffled? Let’s break it down! In this fun crash course, I’ll show you how to convert binary to decimal step-by-step—super easy, no stress. We’ll go from 765,432&#8230;</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-to-decimal-made-easy-fun-crash-course-for-beginners/">Binary to Decimal Made Easy: Fun Crash Course for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed is-type-wp-embed is-provider-rumble-com wp-block-embed-rumble-com"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" title="Binary to Decimal Made Easy: Fun Crash Course for Beginners" src="https://rumble.com/embed/v6pisf7/#?secret=fLsPJTh6ug" data-secret="fLsPJTh6ug" width="1000" height="563" frameborder="0"></iframe>
</div></figure>



<p class="wp-block-paragraph">Binary got you baffled? Let’s break it down! In this fun crash course, I’ll show you how to convert binary to decimal step-by-step—super easy, no stress. We’ll go from 765,432 in decimal to 10101111 in binary (that’s 335, btw), with tricks to eyeball it fast. Perfect for beginners or anyone who loves a good tech challenge. Hit subscribe—I wake up in a cold sweat when you do, and it means the world! More vids coming your way!</p>



<p class="wp-block-paragraph">Introduction to Binary and Decimal 00:00:00<br>Understanding Decimal System 00:00:44<br>Decimal Position Strengths 00:01:39<br>Decimal Formula Explanation 00:03:48<br>Transition to Binary System 00:06:31<br>Binary Position Strengths 00:07:19<br>Binary Formula Breakdown 00:10:46<br>Calculating Binary Example (335) 00:12:55<br>Quick Binary Conversion Trick 00:15:24<br>Memorizing Binary Positions 00:13:52<br>Small Binary Example (19) 00:15:43<br>Closing and Subscription Request 00:16:48</p>



<p class="wp-block-paragraph">Thanks for watching!</p>



<p class="wp-block-paragraph">Find us on other social media here:</p>



<ul class="wp-block-list">
<li>https://www.NeuralLantern.com/social</li>
</ul>



<p class="wp-block-paragraph">Please help support us!</p>



<ul class="wp-block-list">
<li>Subscribing + Sharing on Social Media</li>



<li>Leaving a comment or suggestion</li>



<li>Subscribing to our Blog</li>



<li>Watching the main &#8220;pinned&#8221; video of this channel for offers and extras</li>
</ul>



<p class="wp-block-paragraph">Hello there. Let&#8217;s talk about converting binary to decimal.</p>



<p class="wp-block-paragraph">Just a quick recap for those of you who don&#8217;t know. Watch my other videos if you&#8217;re not sure</p>



<p class="wp-block-paragraph">about number bases, but basically, you know, decimal is a number system that has 10 characters</p>



<p class="wp-block-paragraph">to represent a number. So 0, 1, 2, 4, 5, 6, 7, 8, 9. That&#8217;s 10 characters in decimal.</p>



<p class="wp-block-paragraph">In binary, we just have two characters.</p>



<p class="wp-block-paragraph">So it&#8217;s base two, whereas decimal is base 10.</p>



<p class="wp-block-paragraph">How can we convert between the two?</p>



<p class="wp-block-paragraph">Well, first, before we can try to convert between the two,</p>



<p class="wp-block-paragraph">we should try to understand what&#8217;s really going on with normal decimal representations.</p>



<p class="wp-block-paragraph">So if I have a decimal number here, and I say, I don&#8217;t know,</p>



<p class="wp-block-paragraph">let&#8217;s just type a couple of random numbers.</p>



<p class="wp-block-paragraph">How do we really know what this value is?</p>



<p class="wp-block-paragraph">How do we kind of understand what is the meaning?</p>



<p class="wp-block-paragraph">Okay, so you know that, you know,</p>



<p class="wp-block-paragraph">if you just kind of look at this for a second,</p>



<p class="wp-block-paragraph">you&#8217;ll realize this is 765,000, right?</p>



<p class="wp-block-paragraph">765,432.</p>



<p class="wp-block-paragraph">How do we know that this is 700,000?</p>



<p class="wp-block-paragraph">Because it&#8217;s in a certain position.</p>



<p class="wp-block-paragraph">It&#8217;s like, you know, several digits to the left.</p>



<p class="wp-block-paragraph">How do we know that the next one represents 65,000?</p>



<p class="wp-block-paragraph">Well, it&#8217;s one less to the left.</p>



<p class="wp-block-paragraph">uh it&#8217;s a tenth of the like power of the seven digit same thing for the five how do we know</p>



<p class="wp-block-paragraph">that&#8217;s a thousand same thing for the four and the three and the two what we really do is we end up</p>



<p class="wp-block-paragraph">deciding okay you know what the uh the first digit here on the right side that two uh the strength of</p>



<p class="wp-block-paragraph">of one. So like, you know, two times one is just two. So whatever, whatever that digit is, if it</p>



<p class="wp-block-paragraph">was a five, it would just be a five, five times one is five, right? So the strength of the very</p>



<p class="wp-block-paragraph">first digit on the right side is just one. Every time we move one digit to the left, we multiply</p>



<p class="wp-block-paragraph">the strength by 10. The reason we multiply the strength by 10 is because there are 10 possible</p>



<p class="wp-block-paragraph">digits, or 10 possible characters that we can use in decimal. Makes sense, right? So that means the</p>



<p class="wp-block-paragraph">Makes sense, right?</p>



<p class="wp-block-paragraph">So that means the three, we know that represents, you know, an addition of 30 because that&#8217;s</p>



<p class="wp-block-paragraph">the 10th strength place.</p>



<p class="wp-block-paragraph">Same thing for the four.</p>



<p class="wp-block-paragraph">We multiply 10 by 10 again to get 100 in that position.</p>



<p class="wp-block-paragraph">So this one has a strength of 100.</p>



<p class="wp-block-paragraph">I&#8217;m writing this vertically.</p>



<p class="wp-block-paragraph">Hopefully this is not too messy, but I&#8217;m hoping you&#8217;ll understand.</p>



<p class="wp-block-paragraph">Well, I don&#8217;t know.</p>



<p class="wp-block-paragraph">Maybe if I space this out, does that make it better or worse?</p>



<p class="wp-block-paragraph">maybe it makes it slightly better i don&#8217;t know i&#8217;m going to roll with it</p>



<p class="wp-block-paragraph">what can i say i&#8217;m a rebel okay so i live dangerously the five we know that&#8217;s worth</p>



<p class="wp-block-paragraph">five thousand because again the four position over here you know that third digit it had a</p>



<p class="wp-block-paragraph">strength of 100 so we multiply that strength by 10 going to the left to to end up with a thousand</p>



<p class="wp-block-paragraph">to end up with a thousand.</p>



<p class="wp-block-paragraph">So same thing with the six.</p>



<p class="wp-block-paragraph">I&#8217;m not going to explain that any further.</p>



<p class="wp-block-paragraph">You know, it&#8217;s got a strength of, you know, 10,000.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">And then the seven, it&#8217;s got a strength of 100,000.</p>



<p class="wp-block-paragraph">And it just keeps going and going and going to millions and billions and trillions</p>



<p class="wp-block-paragraph">and however far you actually want to go.</p>



<p class="wp-block-paragraph">That&#8217;s how we understand the decimal numbers</p>



<p class="wp-block-paragraph">that we&#8217;re looking at.</p>



<p class="wp-block-paragraph">How could you imagine this in terms of a formula?</p>



<p class="wp-block-paragraph">Well, we&#8217;re really raising something to the 10th power.</p>



<p class="wp-block-paragraph">If you think about this, the one,</p>



<p class="wp-block-paragraph">we could imagine that the value one</p>



<p class="wp-block-paragraph">is actually 10 to the zero power</p>



<p class="wp-block-paragraph">because anything raised to the zero power is just a one.</p>



<p class="wp-block-paragraph">Let me pull up this calculator real fast.</p>



<p class="wp-block-paragraph">I got to stick that on my desktop in the future.</p>



<p class="wp-block-paragraph">If we say 10 to the zero power, it&#8217;s just one.</p>



<p class="wp-block-paragraph">Any number to the zero power is just one.</p>



<p class="wp-block-paragraph">Okay, so then we would multiply that strength</p>



<p class="wp-block-paragraph">by the actual digit that we see,</p>



<p class="wp-block-paragraph">the character that we see.</p>



<p class="wp-block-paragraph">It&#8217;s a two.</p>



<p class="wp-block-paragraph">Okay, so that&#8217;s going to be two times 10 to the zero power.</p>



<p class="wp-block-paragraph">I&#8217;m going to put that in parentheses</p>



<p class="wp-block-paragraph">to keep it a little bit clean or somewhat cleaner.</p>



<p class="wp-block-paragraph">So now when we go one to the left</p>



<p class="wp-block-paragraph">to look at that three digit,</p>



<p class="wp-block-paragraph">to look at that three digit, we end up with three times something.</p>



<p class="wp-block-paragraph">Let me get a space here for my brain.</p>



<p class="wp-block-paragraph">Times 10 to the something power.</p>



<p class="wp-block-paragraph">Well, every time we go to the left, we just really have to increase the power by one.</p>



<p class="wp-block-paragraph">It&#8217;s 10 to the first power because we&#8217;re looking for actually just the number 10.</p>



<p class="wp-block-paragraph">So if we say 10 to the first power on that calculator, it&#8217;s 10.</p>



<p class="wp-block-paragraph">So then, you know, just keep repeating the process.</p>



<p class="wp-block-paragraph">10 to the second power. And that should be 100. So if I say 10 to the second power, it&#8217;s 100.</p>



<p class="wp-block-paragraph">All right. And, you know, we&#8217;re adding all the positions together, even though we&#8217;re multiplying</p>



<p class="wp-block-paragraph">the digit by its strength. So I&#8217;m going to say five times 10 to the third power. And then again,</p>



<p class="wp-block-paragraph">just to double check here, 10 to the third power is 1000. So you can see the five was supposed to</p>



<p class="wp-block-paragraph">and then again we&#8217;ll say six times ten to the fourth power and then just double check here</p>



<p class="wp-block-paragraph">the fourth power should be a thousand sorry ten thousand and then we&#8217;ll do it one last time we&#8217;ll</p>



<p class="wp-block-paragraph">say seven times ten to the fifth power which should be a hundred thousand all right so now</p>



<p class="wp-block-paragraph">that we&#8217;ve written this all out you know this is kind of madness right what you can do now</p>



<p class="wp-block-paragraph">do now is you can put this into the calculator and it should give you the exact same number that</p>



<p class="wp-block-paragraph">we started with. We should see 765432, unless there&#8217;s a typo. 765432. Nice. Okay, that might</p>



<p class="wp-block-paragraph">have seemed like it was a little bit of a waste of time, but it&#8217;s not because now we kind of</p>



<p class="wp-block-paragraph">understand the breakdown of the different positions of the digits in decimal, which means</p>



<p class="wp-block-paragraph">now we can do the same thing in binary, basically the exact same thing, except just use a power of,</p>



<p class="wp-block-paragraph">use a two to some power rather than a 10 to some power because the only reason we use 10 down here</p>



<p class="wp-block-paragraph">it says we were in decimal that has a base of 10 now let&#8217;s go into binary</p>



<p class="wp-block-paragraph">which is um a base of two so i&#8217;m going to just i guess maybe what did i do wrong</p>



<p class="wp-block-paragraph">i hit something and it like did a space i don&#8217;t even want to know i don&#8217;t even want to know</p>



<p class="wp-block-paragraph">okay so let&#8217;s do a binary number i&#8217;m just going to type a few random digits</p>



<p class="wp-block-paragraph">a few random digits. I don&#8217;t know what number this is yet, but let&#8217;s work it out slowly</p>



<p class="wp-block-paragraph">in the same way. You know what, maybe instead of doing the formula first and only, let&#8217;s do</p>



<p class="wp-block-paragraph">both parts like we did with decimal. So what&#8217;s the position, what&#8217;s the strength of the position</p>



<p class="wp-block-paragraph">for that first character? Well, I said before the first character is always just going to be,</p>



<p class="wp-block-paragraph">sorry, the first digit is always just going to be a one, right? That&#8217;s going to be true</p>



<p class="wp-block-paragraph">So I&#8217;m going to say this has a strength of 1.</p>



<p class="wp-block-paragraph">How do we know it&#8217;s a strength of 1?</p>



<p class="wp-block-paragraph">Because we&#8217;ll take 2 to the something power.</p>



<p class="wp-block-paragraph">We start at 0 for that first position, and it&#8217;s going to give us a 1.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">So the strength of this one, I already know binary.</p>



<p class="wp-block-paragraph">So I just know off the top of my head that to go to the left,</p>



<p class="wp-block-paragraph">the strength just multiplies by 2.</p>



<p class="wp-block-paragraph">And that&#8217;s pretty easy after you start memorizing it.</p>



<p class="wp-block-paragraph">I haven&#8217;t quite memorized hexadecimal yet, but maybe you will in another video.</p>



<p class="wp-block-paragraph">So I&#8217;m going to multiply one by two and I&#8217;m going to end up with two.</p>



<p class="wp-block-paragraph">Double check over here in the calculator.</p>



<p class="wp-block-paragraph">Two to the first power is two.</p>



<p class="wp-block-paragraph">So then the strength of this next digit should be four.</p>



<p class="wp-block-paragraph">Two times two is four, right?</p>



<p class="wp-block-paragraph">So let&#8217;s do two to the second power.</p>



<p class="wp-block-paragraph">That&#8217;s four.</p>



<p class="wp-block-paragraph">Multiply by two again.</p>



<p class="wp-block-paragraph">It&#8217;s going to be eight.</p>



<p class="wp-block-paragraph">Double check over here.</p>



<p class="wp-block-paragraph">Two to the third power is eight.</p>



<p class="wp-block-paragraph">The next digit is going to be 16 of its strength.</p>



<p class="wp-block-paragraph">So I&#8217;m going to write this vertically again.</p>



<p class="wp-block-paragraph">So it&#8217;s going to be 16.</p>



<p class="wp-block-paragraph">Double check over here with the calculator.</p>



<p class="wp-block-paragraph">Double check over here with the calculator, 2 to the 4th power is 16.</p>



<p class="wp-block-paragraph">Next digit is going to be 32.</p>



<p class="wp-block-paragraph">Double check with the calculator, 2 to the 5th power.</p>



<p class="wp-block-paragraph">And things are starting to get messy, so I think I&#8217;m going to like space everything out probably.</p>



<p class="wp-block-paragraph">Just to make it easier to read.</p>



<p class="wp-block-paragraph">Tell me if you think this makes it actually easier to read or if I&#8217;m making it way harder.</p>



<p class="wp-block-paragraph">I think I&#8217;m making it easier.</p>



<p class="wp-block-paragraph">Okay, so we got 32.</p>



<p class="wp-block-paragraph">two. Next one up is going to be 64. Just multiply it by two. Double check two to the sixth power.</p>



<p class="wp-block-paragraph">That&#8217;s going to be 64. And then the biggest one that we&#8217;ve written down is going to be 128.</p>



<p class="wp-block-paragraph">Double check it. Six to the seventh power is 128. We could go on and on and on, but I&#8217;m just going</p>



<p class="wp-block-paragraph">to leave it here because we, I hope we have a pretty good idea of, you know, what this means.</p>



<p class="wp-block-paragraph">delineation or like a delimiter showing us that these are just representing the strengths and</p>



<p class="wp-block-paragraph">this is the actual number. Okay, so how can we write this out in a formula?</p>



<p class="wp-block-paragraph">Whoa, what did I do wrong? Did you see that? Oh no. Hang on a second.</p>



<p class="wp-block-paragraph">I think I missed it. How many digits are there? If there are eight digits, then I definitely forgot</p>



<p class="wp-block-paragraph">something. No, no. Okay. There are nine digits, so the last one should be 256. Okay.</p>



<ol start="256" class="wp-block-list">
<li>Okay. So I got it all lined up. At some point I must have not lined it up. My apologies,</li>
</ol>



<p class="wp-block-paragraph">but hey, maybe I&#8217;m making these mistakes on purpose to make sure that you&#8217;re paying attention.</p>



<p class="wp-block-paragraph">You never know. I want you to think. So 256 is going to be the next number. Double check it with</p>



<p class="wp-block-paragraph">the calculator. Two to the eighth power, 256. Cool. By the way, a quick trick in binary that</p>



<p class="wp-block-paragraph">the actual highest number that you can represent in an unsigned binary integer is basically the</p>



<p class="wp-block-paragraph">strength of the highest digit, you know, this 256 here, multiplied by two and then subtract one</p>



<p class="wp-block-paragraph">from it. So 256 multiplied by two is going to be 512. So it&#8217;s going to be 511. So I could</p>



<p class="wp-block-paragraph">represent a number between zero and 511 or 512 possible combinations. Okay, so now let&#8217;s work</p>



<p class="wp-block-paragraph">let&#8217;s work out the formula.</p>



<p class="wp-block-paragraph">See 16, 30, 16, 40, okay, I did it okay.</p>



<p class="wp-block-paragraph">I probably should have rehearsed this.</p>



<p class="wp-block-paragraph">So let&#8217;s do each position.</p>



<p class="wp-block-paragraph">So it&#8217;s either always gonna be one times something</p>



<p class="wp-block-paragraph">or zero times something, right?</p>



<p class="wp-block-paragraph">Because binary, these characters can only be one or a zero.</p>



<p class="wp-block-paragraph">So let&#8217;s do on the, starting from the right,</p>



<p class="wp-block-paragraph">we&#8217;ll say one times two to the something power.</p>



<p class="wp-block-paragraph">It&#8217;s gonna be two to the zero power</p>



<p class="wp-block-paragraph">You know, just going to be a one.</p>



<p class="wp-block-paragraph">Working our way over to the left, it&#8217;s going to be one times two to the something power</p>



<p class="wp-block-paragraph">to the first power because it just increases every time the power increases.</p>



<p class="wp-block-paragraph">We have four ones in a row here.</p>



<p class="wp-block-paragraph">I got to try to remember that.</p>



<p class="wp-block-paragraph">This is where I&#8217;m going to start making lots and lots of typos.</p>



<p class="wp-block-paragraph">Two to the second power.</p>



<p class="wp-block-paragraph">And then we have another one.</p>



<p class="wp-block-paragraph">One, two, three, four, one times two to the third power.</p>



<p class="wp-block-paragraph">And then again, we are going to hit a zero.</p>



<p class="wp-block-paragraph">So it&#8217;s going to be zero times two to the something power.</p>



<p class="wp-block-paragraph">You might be tempted to omit the zeros.</p>



<p class="wp-block-paragraph">You can if you want to.</p>



<p class="wp-block-paragraph">But for me personally, it helps me quickly visually see that I&#8217;m getting the powers in</p>



<p class="wp-block-paragraph">the right order.</p>



<p class="wp-block-paragraph">I can see two to the zero power, first power, second power, third power, fourth power.</p>



<p class="wp-block-paragraph">Sometimes when I omit the zeros, I end up kind of like messing up the order of the powers</p>



<p class="wp-block-paragraph">and or the order of the exponents.</p>



<p class="wp-block-paragraph">of the exponents and I have to redo everything all over again.</p>



<p class="wp-block-paragraph">So I just keep it this way.</p>



<p class="wp-block-paragraph">Okay, so it&#8217;s one, one, one, one, one, one, one, one, zero.</p>



<p class="wp-block-paragraph">So there&#8217;s another zero that we need</p>



<p class="wp-block-paragraph">times two to the fifth power.</p>



<p class="wp-block-paragraph">So we got both of those zeros now.</p>



<p class="wp-block-paragraph">And then we need another one times two to the sixth power.</p>



<p class="wp-block-paragraph">And then we need</p>



<p class="wp-block-paragraph">0 times 2 to the 7th power.</p>



<p class="wp-block-paragraph">Okay.</p>



<p class="wp-block-paragraph">And then we have another 1 times 2 to the 8th power.</p>



<p class="wp-block-paragraph">And I know we&#8217;re supposed to be done on 8</p>



<p class="wp-block-paragraph">because that&#8217;s what we were doing before.</p>



<p class="wp-block-paragraph">The 256 strength.</p>



<p class="wp-block-paragraph">So unless I made some mistakes here,</p>



<p class="wp-block-paragraph">this is probably the number that we can punch up into the calculator</p>



<p class="wp-block-paragraph">to see what this binary number is.</p>



<p class="wp-block-paragraph">So I&#8217;m going to punch it up.</p>



<p class="wp-block-paragraph">Huge.</p>



<p class="wp-block-paragraph">It says that it&#8217;s the number 335.</p>



<p class="wp-block-paragraph">Let&#8217;s see if that&#8217;s actually right.</p>



<p class="wp-block-paragraph">I&#8217;m going to punch this up in my personal calculator real fast.</p>



<p class="wp-block-paragraph">I&#8217;m going to say 10101111.</p>



<p class="wp-block-paragraph">And the expression is decimal 335.</p>



<p class="wp-block-paragraph">Yep.</p>



<p class="wp-block-paragraph">So that&#8217;s it.</p>



<p class="wp-block-paragraph">We know how to convert from binary to decimal.</p>



<p class="wp-block-paragraph">And just again, like as a quick shorthand,</p>



<p class="wp-block-paragraph">it&#8217;s probably a good idea if you&#8217;re involved in computer science,</p>



<p class="wp-block-paragraph">to memorize these positions up to maybe</p>



<p class="wp-block-paragraph">6, 5, 5, 3, 6.</p>



<p class="wp-block-paragraph">That might sound a little extreme sometimes,</p>



<p class="wp-block-paragraph">but I don&#8217;t know.</p>



<p class="wp-block-paragraph">Personally, I&#8217;m not like the most advanced</p>



<p class="wp-block-paragraph">binary reader at all times,</p>



<p class="wp-block-paragraph">but I can remember up to that much.</p>



<p class="wp-block-paragraph">And what do I mean when I&#8217;m saying that?</p>



<p class="wp-block-paragraph">I&#8217;m saying, you know, start with a 1, 2, 4, 8,</p>



<p class="wp-block-paragraph">8, 2, 56, 5, 12, 1, 2, 4, 2, 0, 4, 8, 4, 0, 9, 6, 8, 1, 9, 2, 1, 6, 3, 8, 4.</p>



<p class="wp-block-paragraph">Took me a while to remember that one.</p>



<p class="wp-block-paragraph">3, 2, 7, 6, 8, 6, 5, 5, 3, 6.</p>



<p class="wp-block-paragraph">So if you think about it, how many bits is this?</p>



<p class="wp-block-paragraph">1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16.</p>



<p class="wp-block-paragraph">Right here, 16.</p>



<p class="wp-block-paragraph">That&#8217;ll give you two bytes worth of memorization or a word on many systems.</p>



<p class="wp-block-paragraph">on many systems. For me personally, I just, I like to go up to 6, 5, 5, 3, 5 because</p>



<p class="wp-block-paragraph">remember I was saying, you know, what is the highest number that you can go up to</p>



<p class="wp-block-paragraph">with a certain number of bits? It&#8217;s always the power or the strength of the highest bit</p>



<p class="wp-block-paragraph">multiplied by two and then subtract one. So when I remember 6, 5, 5, 3, 6, that tells me that if I</p>



<ol start="65535" class="wp-block-list">
<li>This is very, very useful if you&#8217;re going to be working with binary numbers a lot,</li>
</ol>



<p class="wp-block-paragraph">or if you&#8217;re taking exams or whatever it is that you&#8217;re doing, I would recommend everyone do this.</p>



<p class="wp-block-paragraph">Okay. What do you say? What do you say we do another binary number, but we&#8217;ll just do something</p>



<p class="wp-block-paragraph">a little bit smaller to make it easy. Okay. So by the way, when you start to memorize these positions,</p>



<p class="wp-block-paragraph">start to eyeball it, which is really, really fast and a good idea. Like I can see those two</p>



<p class="wp-block-paragraph">numbers right there. I know the first one is a one and the second one is a two. So that means the</p>



<p class="wp-block-paragraph">one and the one are just going to be a value of three. Then I just quickly go, all right, one,</p>



<p class="wp-block-paragraph">two, four, eight, one, two, four, eight, 16. So it&#8217;s going to be 16 plus three. So it&#8217;s going to</p>



<p class="wp-block-paragraph">be 19. I guarantee it. Let&#8217;s, let&#8217;s double check this real fast. We&#8217;ll say one times two to the</p>



<p class="wp-block-paragraph">and then we&#8217;ll say 1 times 2 to the first power</p>



<p class="wp-block-paragraph">and then we&#8217;ll say 0 times 2 to the second power</p>



<p class="wp-block-paragraph">and then we&#8217;ll say 0 times 2 to the third power</p>



<p class="wp-block-paragraph">and then we&#8217;ll say 1 times 2 to the fourth power</p>



<p class="wp-block-paragraph">and if I didn&#8217;t go too fast and make a bunch of typos</p>



<p class="wp-block-paragraph">it should be the number 19</p>



<p class="wp-block-paragraph">So there is a lot of benefit in memorizing the strength of these different positions.</p>



<p class="wp-block-paragraph">I personally never remember very much beyond 256 when I&#8217;m actually trying to work out a number</p>



<p class="wp-block-paragraph">conversion, but when I&#8217;m just thinking of how to compute things, it&#8217;s faster if I can go up to</p>



<ol start="65536" class="wp-block-list">
<li>Okay, I hope you enjoyed this video. I hope you learned a little bit of stuff. I hope</li>
</ol>



<p class="wp-block-paragraph">you had a little bit of fun. I&#8217;ll see you in the next one.</p>



<p class="wp-block-paragraph">Hey everybody! Thanks for watching this video again from the bottom of my heart.</p>



<p class="wp-block-paragraph">I really appreciate it. I do hope you did learn something and have some fun.</p>



<p class="wp-block-paragraph">If you could do me a please, a small little favor, could you please subscribe</p>



<p class="wp-block-paragraph">and follow this channel or these videos or whatever it is you do on the current</p>



<p class="wp-block-paragraph">social media website that you&#8217;re looking at right now. It would really mean the</p>



<p class="wp-block-paragraph">world to me and it&#8217;ll help make more videos and grow this community so we&#8217;ll</p>



<p class="wp-block-paragraph">be able to do more videos, longer videos, better videos or just I&#8217;ll be able to</p>



<p class="wp-block-paragraph">just I&#8217;ll be able to keep making videos in general so please do do me a kindness and uh and subscribe</p>



<p class="wp-block-paragraph">you know sometimes I&#8217;m sleeping in the middle of the night and I just wake up because I know</p>



<p class="wp-block-paragraph">somebody subscribed or followed it just wakes me up and I get filled with joy that&#8217;s exactly what</p>



<p class="wp-block-paragraph">happens every single time so you could do it as a nice favor to me or you could you could troll me</p>



<p class="wp-block-paragraph">if you want to just wake me up in the middle of the night just subscribe and then I&#8217;ll I&#8217;ll just</p>



<p class="wp-block-paragraph">wake up I promise that&#8217;s what will happen also uh if you look at the middle of the screen right now</p>



<p class="wp-block-paragraph">screen right now you should see a QR code which you can scan in order to go to the website which</p>



<p class="wp-block-paragraph">I think is also named somewhere at the bottom of this video and it&#8217;ll take you to my main website</p>



<p class="wp-block-paragraph">where you can just kind of like see all the videos I published and the services and tutorials and</p>



<p class="wp-block-paragraph">things that I offer and all that good stuff and if you have a suggestion for clarifications or</p>



<p class="wp-block-paragraph">errata or just future videos that you want to see please leave a comment or if you just want to say</p>



<p class="wp-block-paragraph">what&#8217;s going on? You know, just send me a comment, whatever. I also wake up for those in the middle</p>



<p class="wp-block-paragraph">of the night. I get, I wake up in a cold sweat and I&#8217;m like, it would really, it really mean the</p>



<p class="wp-block-paragraph">world to me. I would really appreciate it. So again, thank you so much for watching this video</p>



<p class="wp-block-paragraph">and enjoy the cool music as, as I fade into the darkness, which is coming for us all.</p>



<p class="wp-block-paragraph">Thank you.</p>
<p>The post <a href="https://www.NeuralLantern.com/binary-to-decimal-made-easy-fun-crash-course-for-beginners/">Binary to Decimal Made Easy: Fun Crash Course for Beginners</a> appeared first on <a href="https://www.NeuralLantern.com">NeuralLantern.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.NeuralLantern.com/binary-to-decimal-made-easy-fun-crash-course-for-beginners/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
