1 00:00:05,200 --> 00:00:09,350 Welcome back. In this video we're going to configure CodeLite 2 00:00:09,350 --> 00:00:11,350 to run on MacOS 10. 3 00:00:11,350 --> 00:00:13,550 Now I'm running MacOS 10 Catalina, 4 00:00:13,550 --> 00:00:17,750 and I'm installing CodeLite 14.0.0 in this case. 5 00:00:18,300 --> 00:00:21,300 Before we do this, we've got to be sure that the compiler 6 00:00:21,300 --> 00:00:24,000 and CodeLite have been downloaded and installed. 7 00:00:24,000 --> 00:00:28,360 I did that in the previous videos. If you haven't done that please go back and do that. 8 00:00:28,660 --> 00:00:31,660 So again I've installed the compiler and CodeLite. 9 00:00:31,660 --> 00:00:34,260 Now I'm going to run CodeLite for the first time. 10 00:00:34,660 --> 00:00:37,660 You can come up to spotlight search and type CodeLite, 11 00:00:38,020 --> 00:00:42,480 and you can see CodeLite shows up right here version 14.0.0. 12 00:00:42,780 --> 00:00:45,110 And I'm going to double click that to run it. 13 00:00:45,110 --> 00:00:47,310 Now this is pretty normal. 14 00:00:47,310 --> 00:00:50,310 You may or may not get this error message here. 15 00:00:50,710 --> 00:00:54,410 This is very common when you're installing software from the internet that's not 16 00:00:54,410 --> 00:00:56,610 coming from the Apple app store. 17 00:00:56,610 --> 00:01:01,270 It says the CodeLite can't be opened because the developer cannot be verified. 18 00:01:01,570 --> 00:01:04,970 So what does that mean? That just means that you have to allow it to run. 19 00:01:04,970 --> 00:01:09,370 Okay. It's a security feature. So what we're going to do is we're going to cancel here. 20 00:01:10,030 --> 00:01:12,130 And again, you may not get that message. 21 00:01:12,130 --> 00:01:14,330 It all depends on how your system has been set up. 22 00:01:14,830 --> 00:01:18,190 Come up to the Apple, and go to system preferences, 23 00:01:19,070 --> 00:01:23,670 and then you're going to select security and privacy right here let me move this to the center here. 24 00:01:23,970 --> 00:01:25,970 I'm going to select security and privacy, 25 00:01:26,770 --> 00:01:29,130 and then in the first tab, the general tab, 26 00:01:29,130 --> 00:01:33,430 you can see right down here it says CodeLite was blocked from use 27 00:01:33,430 --> 00:01:36,310 because it's not from an identified developer. 28 00:01:36,310 --> 00:01:39,510 Again, all that means is that this app didn't come from the app store. 29 00:01:39,510 --> 00:01:43,010 It came from the internet. So I'm going to select open anyway, 30 00:01:43,010 --> 00:01:44,510 and that will run CodeLite. 31 00:01:45,010 --> 00:01:49,310 And again, now you can see I get the same message, but now I get the open button. 32 00:01:49,310 --> 00:01:53,310 So I'm going to click the open button, and let me close this system preferences 33 00:01:53,670 --> 00:01:56,370 and that's going to run CodeLite for the first time. 34 00:01:57,270 --> 00:02:00,070 And this is what you get the first time you run CodeLite. 35 00:02:00,070 --> 00:02:01,570 Now there's a lot going on here. 36 00:02:01,570 --> 00:02:03,930 I've got a workspace view over here. 37 00:02:03,930 --> 00:02:08,530 I've got a welcome window and it looks like a wizard, it wants to run a setup wizard. 38 00:02:08,530 --> 00:02:12,030 And I also have this message down here that says CodeLite now offers 39 00:02:12,030 --> 00:02:15,690 a better editor color theme. So again, there's a lot going on. 40 00:02:15,690 --> 00:02:20,130 You may or may not get this message down at the bottom about the color theme. 41 00:02:20,130 --> 00:02:23,530 If you do, then what I'd like you to do is cancel the wizard. 42 00:02:23,530 --> 00:02:25,070 We'll run it manually in a moment, 43 00:02:25,570 --> 00:02:28,070 and say yes to this fix. 44 00:02:28,070 --> 00:02:31,670 So I'm going to select Yes right down here on the bottom right, I'm going to click Yes. 45 00:02:32,770 --> 00:02:34,870 And it says a CodeLite restart is needed. 46 00:02:34,870 --> 00:02:37,570 Would you like to restart it now? I'm going to say yes again. 47 00:02:37,570 --> 00:02:40,870 Now CodeLite will close down and restart, 48 00:02:40,870 --> 00:02:43,570 and it should be back in a second. Okay, perfect. 49 00:02:43,570 --> 00:02:47,770 Now what we need to do is we need to run the wizard, the setup wizard. 50 00:02:47,770 --> 00:02:51,070 That's the one we canceled a second ago. So let's run it manually. 51 00:02:51,070 --> 00:02:55,220 We come up to help, run the setup wizard. 52 00:02:55,220 --> 00:02:59,020 Okay, I'll do that again. I'm going to select help, run the setup wizard. 53 00:02:59,020 --> 00:03:03,620 Now it's important that we do this. We only have to do this one time, right now, that's it. 54 00:03:03,620 --> 00:03:06,220 Once this is done, we don't have to do it again. 55 00:03:06,520 --> 00:03:10,020 So welcome to the setup wizard. I'm going to select next. 56 00:03:11,520 --> 00:03:13,520 What's my development profile. In other words, 57 00:03:13,520 --> 00:03:16,020 what kind of development am I going to be doing with CodeLite? 58 00:03:16,020 --> 00:03:18,720 Well, I'm going to be doing cc++ development. 59 00:03:18,720 --> 00:03:21,720 CodeLite supports PHP, JavaScript, 60 00:03:21,720 --> 00:03:25,520 node, I believe. I'm just going to select cc++ development 61 00:03:25,520 --> 00:03:28,720 because that's what this course is about, and select next. 62 00:03:30,320 --> 00:03:34,420 Now this is a really important step. Remember, we've already installed our compilers. 63 00:03:34,420 --> 00:03:38,120 So we're going to let CodeLite set up those compilers for us. 64 00:03:38,120 --> 00:03:40,120 So we're going to click on the scan, 65 00:03:40,120 --> 00:03:43,620 and CodeLite will scan our system for those compilers. 66 00:03:43,620 --> 00:03:44,980 So I'm going to select that now, 67 00:03:46,100 --> 00:03:48,500 and you can see that three compilers show up. 68 00:03:48,500 --> 00:03:52,500 Now that's pretty normal. It's really the same compiler with three different names. 69 00:03:52,500 --> 00:03:56,300 So this is exactly what we want. If nothing comes up here 70 00:03:56,300 --> 00:03:58,900 then it's very likely that you didn't install the compiler. 71 00:03:58,900 --> 00:04:01,900 So go back to the previous videos and install your compiler. 72 00:04:02,500 --> 00:04:06,270 I'll select next. Here you can customize your colors. 73 00:04:06,270 --> 00:04:08,470 I'm just using the defaults here. 74 00:04:08,470 --> 00:04:11,470 The dark, the light, the gray, whatever you prefer. 75 00:04:11,470 --> 00:04:13,970 Again, I'm just selecting the default. 76 00:04:13,970 --> 00:04:15,470 I'll select next. 77 00:04:16,769 --> 00:04:19,070 For white space and indentation, 78 00:04:19,570 --> 00:04:23,820 I'm just going to leave these defaults as they are, and I'm going to select finish. 79 00:04:23,820 --> 00:04:27,480 Now we're done. CodeLite's going to close up and open up again. 80 00:04:27,480 --> 00:04:30,280 And our compilers and our environment should be set up. 81 00:04:30,280 --> 00:04:32,380 First thing, we need to verify that 82 00:04:32,380 --> 00:04:35,020 the compilers were indeed set up correctly. 83 00:04:35,020 --> 00:04:37,620 So we can do that by coming up to settings, 84 00:04:38,500 --> 00:04:39,800 build settings 85 00:04:40,900 --> 00:04:45,300 and then you can see right here under the compilers tab when you select 86 00:04:45,300 --> 00:04:47,300 GCC. We're going to use GCC. 87 00:04:48,000 --> 00:04:52,300 Now the important thing is that when you select GCC and compilers 88 00:04:52,300 --> 00:04:56,300 and then tools, you see stuff here. We see those paths here. 89 00:04:56,300 --> 00:04:58,300 If there's nothing here then again 90 00:04:58,300 --> 00:05:01,960 most likely something went wrong with your compiler installation. 91 00:05:02,660 --> 00:05:05,960 Okay. So that's it. I'm going to select okay, 92 00:05:05,960 --> 00:05:08,160 and our compiler is set up. 93 00:05:08,820 --> 00:05:10,180 Okay. So CodeLite, 94 00:05:10,180 --> 00:05:12,540 as I mentioned, is an integrated development environment, 95 00:05:12,540 --> 00:05:15,140 which means that we can build and run and debug 96 00:05:15,140 --> 00:05:19,240 our c++ programs. It uses a workspace model. 97 00:05:19,240 --> 00:05:21,840 So the idea is that we can create a workspace, 98 00:05:21,840 --> 00:05:26,200 and we create workspaces on this left side here. You can see workspace view up here. 99 00:05:26,200 --> 00:05:29,700 And then we can add multiple projects to a workspace. 100 00:05:29,700 --> 00:05:31,000 Now that's pretty cool. 101 00:05:31,000 --> 00:05:35,000 We can have one workspace, and a whole bunch of different c++ projects within it. 102 00:05:35,550 --> 00:05:37,910 A lot of other IDEs don't work that way. 103 00:05:37,910 --> 00:05:40,570 They basically just allow you to work on one thing at a time. 104 00:05:40,570 --> 00:05:42,870 So this is a pretty nice model here. 105 00:05:42,870 --> 00:05:46,530 Now in order to do that, we need to create a new workspace, right? 106 00:05:46,530 --> 00:05:49,530 There's nothing here. You can see there's a lot of space here, right? 107 00:05:49,530 --> 00:05:53,530 There's nothing going on. So what we're going to do is we're going to create a new workspace. 108 00:05:53,530 --> 00:05:56,130 We can do that by clicking right here on this button. 109 00:05:56,680 --> 00:06:00,880 New workspace or I can come up to appear in the menu bar and click workspace, 110 00:06:00,880 --> 00:06:03,380 new workspace. Again, I could use either one. 111 00:06:03,380 --> 00:06:05,580 I'm going to select this button right here. 112 00:06:06,580 --> 00:06:10,980 And then I get this select workspace type dialog box. 113 00:06:11,530 --> 00:06:14,530 I want to create a c++ workspace. 114 00:06:14,530 --> 00:06:18,630 It's really important that we choose c++ here, and I'll select okay. 115 00:06:19,630 --> 00:06:23,630 Now it's going to ask me where do you want to store this workspace? I'm just going to put it right 116 00:06:23,630 --> 00:06:25,230 in my user directory's, 117 00:06:25,590 --> 00:06:28,290 documents directory or documents folder. 118 00:06:28,290 --> 00:06:30,090 And what's my workspace name? 119 00:06:30,090 --> 00:06:33,090 I'm just going to call it FirstWorkspace. 120 00:06:33,090 --> 00:06:36,750 Here it shows you the complete path to where this file 121 00:06:36,750 --> 00:06:40,050 FirstWorkspace.workspace is going to be stored. 122 00:06:40,550 --> 00:06:45,150 If you want to put it somewhere else, you can just click these three buttons and choose whatever folder you like. 123 00:06:45,700 --> 00:06:49,700 I would encourage you to select that little checkbox down here that way it creates 124 00:06:49,700 --> 00:06:52,300 the workspace in a separate directory 125 00:06:52,300 --> 00:06:55,900 that when we create multiple workspaces they'll be nicely organized. 126 00:06:56,450 --> 00:07:00,110 Now word of warning. Do not use spaces, 127 00:07:00,110 --> 00:07:01,710 special characters. 128 00:07:01,710 --> 00:07:04,270 In other words, don't use spaces like this here, 129 00:07:04,270 --> 00:07:06,630 don't use special characters like 130 00:07:06,630 --> 00:07:10,130 pluses and ampersands and all kinds of weird things. 131 00:07:10,130 --> 00:07:13,430 And don't use any international characters either. 132 00:07:13,930 --> 00:07:16,700 Those will cause all kinds of build issues. 133 00:07:16,700 --> 00:07:21,570 Keep the naming really, really straightforward with everything we do in CodeLite. 134 00:07:22,930 --> 00:07:25,130 Also, if your username, 135 00:07:25,130 --> 00:07:28,330 you can see my username right here is my first name and last name. 136 00:07:28,330 --> 00:07:31,930 If your username has spaces or if it has special characters 137 00:07:31,930 --> 00:07:33,590 or international characters, 138 00:07:33,590 --> 00:07:36,190 then put your workspace somewhere else. 139 00:07:36,190 --> 00:07:38,990 Create a new folder somewhere that doesn't have that 140 00:07:38,990 --> 00:07:41,490 and just store it somewhere else or off your root directory. 141 00:07:41,490 --> 00:07:43,790 We're good to go here. We're going to create the workspace. 142 00:07:43,790 --> 00:07:47,090 Now when I click okay, you're going to see this workspace. 143 00:07:47,090 --> 00:07:50,790 FirstWorkspace appear right up here in the workspace view up in the top left. 144 00:07:50,790 --> 00:07:52,090 So I'm going to click okay, 145 00:07:52,750 --> 00:07:56,650 and here's my workspace. You can see it right there FirstWorkspace. 146 00:07:56,650 --> 00:07:59,450 You can see this whole area here on the right has been 147 00:07:59,450 --> 00:08:00,110 cleared out. 148 00:08:00,110 --> 00:08:03,610 In and of itself the workspace really doesn't do much for us. 149 00:08:03,610 --> 00:08:06,380 It's really a container or a holder for projects. 150 00:08:06,380 --> 00:08:09,680 So what we need to do now is to create our first project, 151 00:08:10,280 --> 00:08:14,880 and we can do that by selecting the workspace and then right clicking on it 152 00:08:15,380 --> 00:08:18,040 and selecting new, new project. Okay. 153 00:08:19,040 --> 00:08:22,400 So I'll do that again. We're going to right click on the workspace, 154 00:08:22,400 --> 00:08:24,900 and then select new, new project. 155 00:08:24,900 --> 00:08:27,230 And now we're going to get a new project wizard. 156 00:08:27,230 --> 00:08:29,930 And this is really important that we get this right. 157 00:08:29,930 --> 00:08:31,330 There's a lot of settings here. 158 00:08:31,330 --> 00:08:34,320 And depending on how we fill them out our projects may or may not build. 159 00:08:34,320 --> 00:08:36,820 So I'll go through this really slowly and carefully. 160 00:08:37,510 --> 00:08:40,010 This is the path to our workspace. 161 00:08:40,210 --> 00:08:43,510 And it's asking us for a new project name right here. 162 00:08:43,510 --> 00:08:45,710 So I'm just going to call this project1. 163 00:08:46,410 --> 00:08:50,770 Again, no spaces, no special characters, no international characters. 164 00:08:50,770 --> 00:08:53,130 Make sure that this checkbox is checked. 165 00:08:53,130 --> 00:08:56,430 Create the project in its own folder under that workspace, 166 00:08:56,430 --> 00:08:58,430 that keeps them nicely organized. 167 00:08:58,730 --> 00:09:02,330 The category, we're going to select console. 168 00:09:04,330 --> 00:09:07,210 The type, we're going to select simple, 169 00:09:07,210 --> 00:09:10,810 executable g++, right there you can see simple 170 00:09:10,810 --> 00:09:14,310 executable g++. Don't choose anything else. 171 00:09:14,710 --> 00:09:17,710 The compiler, we're going to use is GCC. 172 00:09:18,210 --> 00:09:22,310 And the debugger, we're going to use is different from the ones that we use on windows 173 00:09:22,310 --> 00:09:24,010 or ubuntu Linux. 174 00:09:24,010 --> 00:09:26,610 Those of you who are using multiple operating systems, 175 00:09:26,610 --> 00:09:30,210 we're going to use the LLDB debugger, that's Apple's debugger. 176 00:09:31,210 --> 00:09:35,410 And then the last thing and this is probably the most important one is the build system. 177 00:09:35,410 --> 00:09:38,110 We want to be sure that we select default. 178 00:09:39,210 --> 00:09:40,710 Okay, default. 179 00:09:41,210 --> 00:09:43,910 So I'll leave this screen up for a second. You can pause the video, 180 00:09:43,910 --> 00:09:46,410 and I'm going to go through this one more time while you do that. 181 00:09:46,410 --> 00:09:51,010 We've got our workspace up here. We've got the name of our project that we're going to create. 182 00:09:51,510 --> 00:09:55,910 Again, no spaces. No special characters. No international characters. 183 00:09:56,270 --> 00:10:00,370 You're probably tired of hearing that, but it's really important because the majority of build 184 00:10:00,370 --> 00:10:04,270 errors that I see in the QA forums is because students put 185 00:10:04,270 --> 00:10:07,270 really strange characters and there are spaces, so don't do that. 186 00:10:07,770 --> 00:10:11,870 Make sure that this checkbox is checked. The category is console. 187 00:10:12,170 --> 00:10:18,970 The type is simple executable g++. 188 00:10:18,970 --> 00:10:21,170 The compiler is GCC. 189 00:10:21,170 --> 00:10:25,370 The debugger is the Apple debugger LLDB. And finally, 190 00:10:25,370 --> 00:10:27,670 the most important on the build system is default. 191 00:10:28,870 --> 00:10:31,230 When I click okay, you'll see a project 192 00:10:31,230 --> 00:10:34,430 created over here under the workspace, called project1. 193 00:10:34,430 --> 00:10:38,230 And I put a special character in there by accident that would have been not good. 194 00:10:38,230 --> 00:10:40,230 So let me select okay. 195 00:10:42,230 --> 00:10:44,830 And here you go. There's the project, project1. 196 00:10:44,830 --> 00:10:48,630 You can expand these or contract them by selecting the chevron. 197 00:10:48,630 --> 00:10:51,400 You can see project1 has a source folder in there, 198 00:10:51,400 --> 00:10:54,700 and that source folder has a main CPP file. 199 00:10:54,700 --> 00:10:56,000 That's our source code. 200 00:10:56,550 --> 00:10:58,750 That's what we're going to type our programs into. 201 00:10:58,750 --> 00:11:02,050 Now I can't see it over here because I haven't selected it. 202 00:11:02,050 --> 00:11:04,650 So I'm just going to double click main.cpp. 203 00:11:05,150 --> 00:11:07,350 And now you can see the source code. 204 00:11:07,350 --> 00:11:10,250 Now this is c source code, not c++ source code. 205 00:11:10,250 --> 00:11:12,850 So we're going to change this in a minute. And we're going to write our own. 206 00:11:13,250 --> 00:11:17,810 But it's important that you be able to see this here. So double click on main CPP and 207 00:11:17,810 --> 00:11:19,360 that's what you're going to see. Now 208 00:11:19,360 --> 00:11:21,360 this font is a little bit small. 209 00:11:21,360 --> 00:11:23,360 So what I'm going to do is I'm going to make it larger. 210 00:11:23,360 --> 00:11:26,360 You don't have to do this on your end because it's probably fine for you but I think a 211 00:11:26,360 --> 00:11:28,960 bigger font will be easier for you to see on video. 212 00:11:29,460 --> 00:11:31,460 So I'm going to select the font. 213 00:11:31,460 --> 00:11:35,460 And I'm just going to make it size, let's make it 18, 214 00:11:35,460 --> 00:11:39,660 so you can really see it. I'll select okay, apply okay 215 00:11:40,160 --> 00:11:42,360 and that should be a little bit better I think. 216 00:11:42,360 --> 00:11:46,260 Okay so now what we're going to do is we're going to write our very first c++ program. 217 00:11:46,260 --> 00:11:48,760 So I'm going to delete all of this stuff right here. 218 00:11:49,860 --> 00:11:53,410 And I know you're going to have some questions as I type this. 219 00:11:53,410 --> 00:11:55,910 Just type along, follow along. 220 00:11:55,910 --> 00:11:57,710 All this will be explained in the course. 221 00:11:57,710 --> 00:12:02,700 The importance of this video is to be sure that you can build c++ programs. 222 00:12:02,700 --> 00:12:06,300 So again, type along, follow along. All this is going to be explained. 223 00:12:06,960 --> 00:12:09,620 So the first thing we're going to type is #include, 224 00:12:09,620 --> 00:12:13,620 followed by a space and then followed by iostream 225 00:12:13,820 --> 00:12:16,420 in angle brackets, and I'm going to press enter. 226 00:12:16,420 --> 00:12:20,320 Now the pound is the hashtag. We call it pound in c++. 227 00:12:20,320 --> 00:12:22,580 So again, pound includes space 228 00:12:22,580 --> 00:12:27,180 iostream in angle brackets or less than greater than sign in the end. Okay. 229 00:12:28,060 --> 00:12:31,460 Now we're going to type our main function. So I'm going to type int, 230 00:12:32,160 --> 00:12:35,660 followed by a space, followed by the word main, 231 00:12:36,460 --> 00:12:39,960 followed by a left parenthesis a space and a right parenthesis. 232 00:12:40,460 --> 00:12:42,960 Now we're going to type in left curly brace. 233 00:12:43,860 --> 00:12:45,520 And I'm going to press enter. 234 00:12:45,520 --> 00:12:50,120 Now you'll notice that the IDE automatically put the curly that closes, 235 00:12:50,120 --> 00:12:53,420 the right closing curly brace. So I'll do that again. 236 00:12:53,420 --> 00:12:57,120 I'll put in a left one, press enter. You can see it's closed it for me. 237 00:12:57,120 --> 00:12:59,720 That's one of the nice things that IDEs do. 238 00:12:59,720 --> 00:13:03,520 Now what we're going to do is we're going to type a couple lines of code and that's it. We're going to type 239 00:13:03,520 --> 00:13:07,320 STD, followed by two colons, 240 00:13:08,120 --> 00:13:09,920 followed by cout. 241 00:13:12,120 --> 00:13:16,320 Okay so std::cout then a space, followed by 242 00:13:16,870 --> 00:13:19,970 two less than signs, no space between them 243 00:13:19,970 --> 00:13:22,170 and then we're going to type Hello Testing 244 00:13:22,970 --> 00:13:24,970 inside double quotes, 245 00:13:26,070 --> 00:13:28,630 just like that then another space, 246 00:13:29,430 --> 00:13:32,390 two more less than signs, and we're going to type std 247 00:13:33,050 --> 00:13:34,750 endl, 248 00:13:35,850 --> 00:13:37,850 and a semicolon at the end 249 00:13:38,750 --> 00:13:43,110 and then return zero on the next line, followed by a semicolon. 250 00:13:43,110 --> 00:13:44,610 That's our program. 251 00:13:44,610 --> 00:13:48,610 So again, pounded include iostream in angle brackets. 252 00:13:48,610 --> 00:13:52,910 Int main with two parentheses there, open one and a closed one. 253 00:13:53,310 --> 00:13:55,910 The curly brace std 254 00:13:56,410 --> 00:13:58,010 ::cout, 255 00:13:58,010 --> 00:14:01,310 two less than signs, hello testing and quotes, 256 00:14:01,310 --> 00:14:02,610 two less than signs, 257 00:14:02,610 --> 00:14:06,010 std::end; 258 00:14:06,010 --> 00:14:10,000 and return zero. It's a lot harder to say than it is to write. 259 00:14:10,000 --> 00:14:13,300 Make sure you've got semicolons on the ends of these lines. 260 00:14:13,900 --> 00:14:17,900 And what does this do? Well we're, including the iostream library, 261 00:14:17,900 --> 00:14:21,800 so that we can do input output. In this case, we're only going to do output. 262 00:14:21,800 --> 00:14:25,400 And what we're doing here in this function is we're displaying Hello Testing 263 00:14:25,400 --> 00:14:29,760 to the console. That's it. And we're putting a new line at the end to go to the next line. 264 00:14:29,760 --> 00:14:32,960 Okay. We're returning zero because main always returns zero, 265 00:14:32,960 --> 00:14:37,560 and we'll get to all of this in the class as they say stay tuned more is coming. 266 00:14:38,160 --> 00:14:42,660 Now one of the things that we need to do is we need to save this before we build it and run it. 267 00:14:43,160 --> 00:14:47,160 So notice it over here, you see that red bar going between the 268 00:14:47,160 --> 00:14:51,560 one and the six right there.That's telling you that you haven't saved this. 269 00:14:51,810 --> 00:14:54,310 So how do you save it, you can come up to file, save file. 270 00:14:54,810 --> 00:14:58,610 Now you'll notice save file is grayed out. 271 00:14:58,610 --> 00:15:01,490 This is a bug in this version of CodeLite, 272 00:15:01,490 --> 00:15:04,690 but the command works. The command s works, 273 00:15:04,690 --> 00:15:08,350 which is what I'm going to use. So what I'm going to do is I'm going to press command 274 00:15:08,350 --> 00:15:09,710 s to save this. 275 00:15:09,710 --> 00:15:12,370 And you'll notice that this red line will turn green. 276 00:15:12,370 --> 00:15:14,970 So I'm going to do that right now I'm going to press command s. 277 00:15:14,970 --> 00:15:17,570 Notice it's green now that's because I just saved it. 278 00:15:17,570 --> 00:15:19,450 That's really important that you save it. 279 00:15:19,450 --> 00:15:22,950 So our program is written, and we're almost ready to run it. 280 00:15:22,950 --> 00:15:25,950 We just need to make a couple of changes to the project. 281 00:15:25,950 --> 00:15:29,150 And we'll do that right now. We'll click 282 00:15:29,150 --> 00:15:32,150 on the project name right over here in the workspace view. 283 00:15:32,810 --> 00:15:34,310 And I'm going to right click it 284 00:15:34,310 --> 00:15:38,210 and then come all the way to the bottom of these options and select settings. 285 00:15:39,510 --> 00:15:42,840 And now I'm going to get a settings screen for my project. 286 00:15:43,940 --> 00:15:47,440 Over here, it says general and we don't have to change any of this stuff. 287 00:15:47,440 --> 00:15:51,740 This is the stuff that we -- that automatically got set up for us 288 00:15:51,740 --> 00:15:55,140 when we created the project in the project wizard. 289 00:15:55,140 --> 00:15:58,140 But what we do want to do is we want to click compiler here. 290 00:15:58,140 --> 00:16:01,140 And we want to make a couple of changes to the compiler. 291 00:16:01,140 --> 00:16:05,040 So we're going to click compiler, and go up to c++ compiler options 292 00:16:05,040 --> 00:16:05,940 right here. 293 00:16:06,740 --> 00:16:09,040 And I'm going to click right over here on the right. 294 00:16:09,040 --> 00:16:12,940 And you'll notice this button with the three dots shows up right here. 295 00:16:12,940 --> 00:16:17,040 Click on that and what we want to do here is 296 00:16:17,040 --> 00:16:18,740 I'm going to scroll all the way up here. 297 00:16:19,640 --> 00:16:23,300 And I want to be sure that I've selected c++ 17, 298 00:16:23,300 --> 00:16:26,600 right here, enable c++ 17.That's important. 299 00:16:26,900 --> 00:16:31,890 So I've selected that. Up at the top I want to enable all compiler warnings. 300 00:16:32,880 --> 00:16:35,550 I've selected that. You can see as I click these, 301 00:16:35,550 --> 00:16:38,220 and that's a little bug there too huh it doesn't show up. 302 00:16:38,220 --> 00:16:41,880 Well, as I click these, you can see the commands down here, 303 00:16:41,880 --> 00:16:44,080 right. In the command line, you can see the switches. 304 00:16:44,080 --> 00:16:48,380 So there's really four things we want. We want to see the w all down here. 305 00:16:48,880 --> 00:16:53,280 We want to enable c++ 17 down here, you can see it right there. 306 00:16:54,380 --> 00:16:57,680 And there's two more. One is optimize for debugging, 307 00:16:57,680 --> 00:17:01,240 and the other is produce debugging information. Those are the four 308 00:17:01,240 --> 00:17:03,440 that we want to have enabled. 309 00:17:03,940 --> 00:17:06,240 Once we've got those enabled, 310 00:17:07,240 --> 00:17:09,240 we'll click okay. Apply and then okay. 311 00:17:10,339 --> 00:17:13,700 So our program is done. Our project is set up. 312 00:17:13,700 --> 00:17:18,000 Now you may think, Wow do I have to do these steps every time I create a project? 313 00:17:18,000 --> 00:17:21,500 Yes, but we'll create a project template in a couple of videos 314 00:17:21,500 --> 00:17:24,000 from now that way you can create the one template. 315 00:17:24,000 --> 00:17:26,900 Create projects from it, you don't have to do this ever again. 316 00:17:26,900 --> 00:17:30,400 So at this point, we want to come up to build 317 00:17:31,100 --> 00:17:33,200 and then build and run the project. 318 00:17:33,200 --> 00:17:36,200 What that's going to do is it's going to compile the project and run it. 319 00:17:36,200 --> 00:17:37,800 So let's do that right now. 320 00:17:38,350 --> 00:17:40,950 And if we don't have any errors, our project will run. 321 00:17:40,950 --> 00:17:43,950 Hopefully, I didn't have any typos. I'm going to select that, 322 00:17:46,310 --> 00:17:48,210 and our program is running. 323 00:17:48,210 --> 00:17:51,310 This is what pops up. This is a terminal window. 324 00:17:51,860 --> 00:17:54,220 And you can see this last login information. 325 00:17:54,220 --> 00:17:57,420 I'll show you another option for a Mac that can come in handy. 326 00:17:57,420 --> 00:18:00,720 But you can see right here is the important part, Hello Testing. 327 00:18:00,970 --> 00:18:04,870 That's exactly what our program did. You can see the Hello Testing up here. 328 00:18:04,870 --> 00:18:08,270 Hit any key to continue. I'll just press any key 329 00:18:08,270 --> 00:18:12,070 that goes away,and our program is done. Everything worked correctly. 330 00:18:12,070 --> 00:18:14,070 Now down here is the output view. 331 00:18:14,570 --> 00:18:16,570 And there's two important tabs here. 332 00:18:16,570 --> 00:18:18,970 The first one is this one, the output tab. 333 00:18:18,970 --> 00:18:21,270 Now this doesn't show you the output of the program. 334 00:18:21,270 --> 00:18:25,260 It shows you the output of when we ran the program of how it's being run. 335 00:18:25,260 --> 00:18:29,260 So this working directory here. This is important because sometimes 336 00:18:29,260 --> 00:18:30,760 it'll help us understand 337 00:18:30,760 --> 00:18:34,660 when we're having problems. Something won't run correctly. We can look here. 338 00:18:35,210 --> 00:18:39,210 The other important tab is this build tab. Now this one's much more important. 339 00:18:39,460 --> 00:18:42,760 This tells us what happened during the build of our project. 340 00:18:42,760 --> 00:18:46,260 You can see that I'm running the compiler here g++. 341 00:18:46,260 --> 00:18:49,560 You can see the file that it's running it on, main CPP. 342 00:18:49,560 --> 00:18:52,060 You can see those options we set up and so forth. 343 00:18:52,720 --> 00:18:55,220 Zero errors, zero warnings. That's good. 344 00:18:55,820 --> 00:18:57,520 What could go wrong 345 00:18:57,520 --> 00:19:01,020 and where do errors show up? Well, the errors would show up right down here. 346 00:19:01,020 --> 00:19:04,020 So suppose that I forgot that semicolon right there, 347 00:19:04,680 --> 00:19:08,180 and notice that this is red right here now and the rest is green. 348 00:19:08,180 --> 00:19:12,580 So I have made a change. I need to save. So I can press command s. 349 00:19:13,480 --> 00:19:15,680 And I just saved it. It's all green now. 350 00:19:15,680 --> 00:19:18,680 And now I've come up to build, build and run. 351 00:19:18,680 --> 00:19:22,080 It's going to give me an error because I forgot that semicolon. 352 00:19:22,080 --> 00:19:25,580 So I'm going to run it and you could see down here 353 00:19:25,580 --> 00:19:30,080 that the build ended with errors. Do I want to continue? Well, no. I don't want to continue. 354 00:19:30,080 --> 00:19:31,580 I want to fix my errors. 355 00:19:31,580 --> 00:19:36,980 So in this case, you can see the red text right here, it says expected semicolon. 356 00:19:36,980 --> 00:19:39,180 And if you click on that red text, 357 00:19:39,680 --> 00:19:44,280 this little red arrow pops up here and kind of tells you it helps you out. It's like something's not 358 00:19:44,280 --> 00:19:48,480 right here. Between the error code and the arrow up here, 359 00:19:48,480 --> 00:19:51,480 you can kind of tell what's going on, right. So I'm going to press the 360 00:19:51,840 --> 00:19:54,940 put the semicolon back in, save again. 361 00:19:54,940 --> 00:19:57,140 So you got red here so I'm going to save again, 362 00:19:57,140 --> 00:19:59,940 and I can build and run and it should build and run just fine. 363 00:19:59,940 --> 00:20:03,040 Now common errors that I see in this first program 364 00:20:03,040 --> 00:20:05,240 for getting semicolons is very common. 365 00:20:05,840 --> 00:20:09,500 Some students if when you see these left parent, 366 00:20:09,500 --> 00:20:12,600 right parent, sometimes that looks let me -- 367 00:20:12,600 --> 00:20:15,960 put a couple extra ones there. Sometimes that looks like a zero. 368 00:20:15,960 --> 00:20:18,960 So students type main zero and that's incorrect. 369 00:20:18,960 --> 00:20:21,960 It has to be a left parent followed by a right parent. 370 00:20:22,620 --> 00:20:26,620 And the other thing I see is this word up here gets misspelled a lot 371 00:20:27,420 --> 00:20:31,780 it's iostream. It's not iosteam. It's iostream 372 00:20:31,780 --> 00:20:35,280 with an r but often that happens. 373 00:20:35,280 --> 00:20:39,440 I guess, we're used to writing steam and not stream. So I'm going to change that to stream. 374 00:20:39,440 --> 00:20:43,640 I'm going to save. And when I run the program again, it'll run just fine. 375 00:20:43,640 --> 00:20:47,540 I don't particularly like the terminal window that you just saw. 376 00:20:47,540 --> 00:20:51,640 I like to change that in CodeLite. So I like to come up to in - on Mac. 377 00:20:51,640 --> 00:20:54,530 I like to come up to CodeLite preferences here. 378 00:20:55,890 --> 00:20:59,490 And then down at the bottom of the preferences, you'll see terminal. 379 00:21:00,590 --> 00:21:04,190 And right now the default is Terminal. That's the one you just saw. 380 00:21:04,190 --> 00:21:08,190 You can choose iTerm 2 or CodeLite terminal. I tend to like codelite terminal. 381 00:21:08,190 --> 00:21:12,070 So I'm going to select that and I'll run it so you can see 382 00:21:12,070 --> 00:21:13,870 how what it looks like in this terminal. 383 00:21:13,870 --> 00:21:17,070 The problem with using Terminal 384 00:21:17,070 --> 00:21:21,670 is that sometimes you get a whole bunch of terminals. It doesn't tend to close correctly all the time. 385 00:21:21,670 --> 00:21:25,330 So I'm going to select CodeLite terminal, apply 386 00:21:25,580 --> 00:21:26,780 select okay. 387 00:21:27,330 --> 00:21:31,010 And now when I run, I'm going to build and run a project again. 388 00:21:33,710 --> 00:21:36,010 You can see what the CodeLite terminal looks like. 389 00:21:37,010 --> 00:21:40,610 Now it says it needs access to my documents folder. 390 00:21:41,670 --> 00:21:44,570 I'm going to allow it and you only have to do that once, there you go. Hello Testing! 391 00:21:44,570 --> 00:21:46,170 Hit any key to continue. 392 00:21:46,170 --> 00:21:50,380 This to me this looks a lot cleaner than the other terminal it has a lot of stuff in it. 393 00:21:50,380 --> 00:21:54,040 But it's your choice. You can use whichever one you like. They both work okay. So again I'm going to 394 00:21:54,040 --> 00:21:55,700 press any key. So that's it. 395 00:21:55,700 --> 00:21:59,690 We've written our very first c++ program. We've gotten it to build. 396 00:21:59,690 --> 00:22:04,090 If you have any errors or any issues that are beyond the semicolon and so forth, 397 00:22:04,090 --> 00:22:06,090 you're getting strange error messages. 398 00:22:06,090 --> 00:22:08,090 Post it on the forum, 399 00:22:08,090 --> 00:22:12,690 and you can see here it says it CodeLite restart is needed that's because I changed the setting. 400 00:22:12,690 --> 00:22:14,690 You can just say yes, and I'll say that in a minute. 401 00:22:14,690 --> 00:22:19,190 But on the forum, I might say show me your build output. 402 00:22:19,190 --> 00:22:21,990 And what I want is this part right down here. 403 00:22:21,990 --> 00:22:24,190 So you could just copy and paste this stuff 404 00:22:24,190 --> 00:22:28,390 or you could just give me a screenshot and post it in the QA forum if you have any errors. 405 00:22:28,390 --> 00:22:31,590 And it's really easy to figure it out here for me, and I'll 406 00:22:31,840 --> 00:22:33,640 let you know how to fix it if I can. 407 00:22:33,640 --> 00:22:37,640 If you follow these settings and write this code like this, you should be just fine. 408 00:22:37,640 --> 00:22:40,140 All right. So that wraps up this video. 409 00:22:40,140 --> 00:22:44,140 I'll see you on the next video, and we'll start writing some c++ code.