1 00:00:04,939 --> 00:00:08,960 In this video, we'll run and configure code light on Mac OS ten. 2 00:00:09,050 --> 00:00:12,640 Now we've already installed the compiler tools and we've installed code light. 3 00:00:12,650 --> 00:00:19,040 So let's run code light, we'll come up to spotlight, search and type code light and double click on 4 00:00:19,040 --> 00:00:19,820 the icon. 5 00:00:25,250 --> 00:00:26,600 We'll allow it to run. 6 00:00:32,360 --> 00:00:35,560 Now the first time that code light runs, a couple of things will happen. 7 00:00:35,570 --> 00:00:39,800 You'll get this small code light window show up and then you'll get a setup wizard. 8 00:00:40,970 --> 00:00:42,740 We can just leave that window smallest. 9 00:00:42,770 --> 00:00:44,120 We'll make it larger in a minute. 10 00:00:44,120 --> 00:00:45,830 It's not really going to get in our way right now. 11 00:00:45,850 --> 00:00:48,170 It's important is that we run this setup wizard. 12 00:00:48,320 --> 00:00:56,270 If the setup wizard does not start, come up to code lights menu and go up to help and then run the 13 00:00:56,270 --> 00:00:58,760 setup wizard and run it manually. 14 00:00:59,390 --> 00:01:01,100 But here in this case, it did pop up. 15 00:01:01,100 --> 00:01:02,600 So let's select next. 16 00:01:05,780 --> 00:01:11,480 Code Light uses a bunch of plug ins to allow support for PHP and Node and other technologies. 17 00:01:11,480 --> 00:01:12,680 We don't really want all that. 18 00:01:12,680 --> 00:01:14,930 We only want the C++ plug ins. 19 00:01:15,020 --> 00:01:17,300 The rest are just going to clutter up our interface. 20 00:01:17,300 --> 00:01:23,720 So what we can do here is we can press clear and then just toggle the C++ plugins that way. 21 00:01:23,720 --> 00:01:27,020 Only some of these will show up, which is exactly what we want. 22 00:01:27,020 --> 00:01:30,800 We just want to concentrate on C++, Select next. 23 00:01:32,270 --> 00:01:35,510 Now we can scan our computer for any installed compilers. 24 00:01:35,510 --> 00:01:42,920 We can press this button here and you can see it's found DCC Clang and across DCC we're going to use 25 00:01:42,920 --> 00:01:43,790 GCC. 26 00:01:43,820 --> 00:01:48,440 They're really the same, but we'll use GCC here and press next. 27 00:01:49,160 --> 00:01:51,950 Now the customization of the theme is really up to you. 28 00:01:51,950 --> 00:01:53,480 This is your personal preference. 29 00:01:53,480 --> 00:01:59,210 The monarchy dark theme is real nice and easy on the eyes, but it doesn't show up too well on video. 30 00:01:59,210 --> 00:02:04,280 So I'm going to select the classic Eclipse theme and select next. 31 00:02:05,030 --> 00:02:07,730 We'll keep these defaults and press finish. 32 00:02:09,740 --> 00:02:13,130 Now, what we can do here is we can say save and exit. 33 00:02:13,130 --> 00:02:16,490 You want to be sure that you save so we can save the changes we've made 34 00:02:19,850 --> 00:02:21,710 and we can run code light again. 35 00:02:31,070 --> 00:02:33,230 So this time I want to make this window nice and big 36 00:02:35,870 --> 00:02:38,690 and we've got a couple of options that we still need to configure. 37 00:02:38,690 --> 00:02:41,240 But before we do that, we need to create a workspace. 38 00:02:41,900 --> 00:02:49,460 You can create a workspace by clicking this button here or by coming up to file new workspace. 39 00:02:49,460 --> 00:02:50,990 Either place works fine. 40 00:02:51,140 --> 00:02:57,230 A workplace is just an area where we can have our C++ projects, so we can have multiple projects in 41 00:02:57,230 --> 00:02:58,040 a workspace. 42 00:02:58,040 --> 00:03:03,200 So I'm going to select new workspace, and the workspace name could be anything you like. 43 00:03:03,320 --> 00:03:05,720 I'm going to say keep workspace. 44 00:03:07,340 --> 00:03:10,040 Don't use any spaces here, just keep it all together. 45 00:03:10,490 --> 00:03:15,650 And I want to create the workspace under a separate directory so I can keep my files organized. 46 00:03:15,680 --> 00:03:16,760 I'll select, okay. 47 00:03:17,570 --> 00:03:20,930 And you can see that it's created the workspace over here on the left pane. 48 00:03:21,440 --> 00:03:30,020 Now we need to create a C++ project so you can right click on that and select new project, or you can 49 00:03:30,020 --> 00:03:33,620 select the workspace and then come up to file new project. 50 00:03:33,620 --> 00:03:38,150 Either way, now we've got some options. 51 00:03:38,510 --> 00:03:46,160 We're going to create console project and simple executable G plus plus right here. 52 00:03:46,850 --> 00:03:53,450 And that's the compiler we're going to use and we'll select next the project name again. 53 00:03:53,450 --> 00:03:54,890 Don't use any spaces here. 54 00:03:54,890 --> 00:03:58,490 Just create your name, the name for your project, whatever you like. 55 00:03:59,420 --> 00:04:03,710 I'm again, I'm going to create a separate directory for each project and I'll select next. 56 00:04:06,050 --> 00:04:11,370 As far as the compiler, we want to use the GCC compiler, but the debugger, we don't want to use the 57 00:04:11,390 --> 00:04:14,300 new debugger, we want to use the LTB debugger. 58 00:04:14,300 --> 00:04:15,530 That's the Apple debugger. 59 00:04:16,100 --> 00:04:17,329 We'll select finish. 60 00:04:18,019 --> 00:04:22,550 And you can see over here on the left that we've created a project called Test one and it's got a source 61 00:04:22,550 --> 00:04:25,640 directory and it's got a file there called Main CP. 62 00:04:25,670 --> 00:04:29,840 Now before we run that file, there's a couple of things that we need to set up. 63 00:04:30,020 --> 00:04:37,430 First click on the project in this case, test one right click and then come down to settings and select 64 00:04:37,430 --> 00:04:37,910 that. 65 00:04:39,140 --> 00:04:45,680 Then down here toward the bottom where you see global settings come up to compiler options and select 66 00:04:45,680 --> 00:04:46,760 the right side. 67 00:04:46,760 --> 00:04:49,520 And then you'll see this little button right here with the three dots. 68 00:04:49,520 --> 00:04:50,480 Select that. 69 00:04:51,350 --> 00:04:54,620 And what we want to do here is we want to check a couple of options. 70 00:04:54,840 --> 00:05:01,250 We scroll all the way up and I want to select enable all compiler warnings wall and I want to enable 71 00:05:01,280 --> 00:05:03,200 C++ 14 features. 72 00:05:03,200 --> 00:05:04,460 That's the latest standard. 73 00:05:04,460 --> 00:05:06,050 That's modern C++. 74 00:05:06,050 --> 00:05:11,540 I want to make sure that that's enabled and this guy doesn't come on, but you can see that it is there 75 00:05:11,540 --> 00:05:13,550 something sometimes it doesn't check on. 76 00:05:13,970 --> 00:05:15,680 You can see that the command line is correct. 77 00:05:15,680 --> 00:05:16,610 So just click. 78 00:05:16,610 --> 00:05:19,460 Okay, I'll apply and click. 79 00:05:19,460 --> 00:05:20,690 Okay, perfect. 80 00:05:20,690 --> 00:05:27,380 Now go to the workspace, select it right click on it and come down to workspace settings. 81 00:05:28,670 --> 00:05:35,450 And you'll see we have environment and code completion, select code completion and check the Enable 82 00:05:35,450 --> 00:05:37,400 C++ 14 standard. 83 00:05:38,390 --> 00:05:41,450 The Integrated Development Environments use code completion. 84 00:05:41,450 --> 00:05:45,350 They try to figure out what you're typing and what you want to do and where you want to go and really 85 00:05:45,350 --> 00:05:46,940 help you out with suggestions. 86 00:05:46,940 --> 00:05:51,710 In this case, we're simply telling code light to use the C++ 14 standard. 87 00:05:51,710 --> 00:05:54,350 For those suggestions, I'll click. 88 00:05:54,350 --> 00:05:57,140 Okay, and that's it for the setup. 89 00:05:57,470 --> 00:06:00,860 Now let's modify this C++ file and run it. 90 00:06:01,790 --> 00:06:03,260 Let's double click on that. 91 00:06:03,680 --> 00:06:06,440 And that font is really small. 92 00:06:06,440 --> 00:06:09,980 So what I'm going to do is I'm going to make it a little larger so it shows up better on the video. 93 00:06:09,980 --> 00:06:11,990 Most likely you won't have to touch it at all. 94 00:06:11,990 --> 00:06:20,390 But I'm just going to come to settings, colors and fonts, and I'll set the font to, let's say 18 95 00:06:23,210 --> 00:06:27,110 and I'll apply that and that should be much more readable. 96 00:06:27,890 --> 00:06:29,630 Okay, so now let's modify this file. 97 00:06:29,630 --> 00:06:31,820 This is actually C code, not C++ code. 98 00:06:31,820 --> 00:06:39,320 So let's get rid of all this and we'll type a simple C++ program that will test our installation during 99 00:06:39,320 --> 00:06:39,890 this course. 100 00:06:39,890 --> 00:06:45,230 I will go in detail through the anatomy of a C++ program, and everything that I'll be typing here will 101 00:06:45,230 --> 00:06:46,010 be explained. 102 00:06:46,010 --> 00:06:50,480 But for now, just follow along, type along to make sure we've got a clean install. 103 00:06:50,480 --> 00:06:57,230 So the first thing you want to do is going to type pound include and we want to put IO stream in angled 104 00:06:57,230 --> 00:07:04,190 brackets and press enter then int space main left and right paren. 105 00:07:05,000 --> 00:07:10,640 Then we want to open up a left curly and you can see that the IDE has closed it for me. 106 00:07:11,030 --> 00:07:17,150 And then what I want to do here is I just want to say STD two colon side by side, no spaces and then 107 00:07:17,150 --> 00:07:26,600 see out the insertion operator, which is two less than sines again together with no spaces and anything 108 00:07:26,600 --> 00:07:27,740 you want to type here as far as. 109 00:07:27,740 --> 00:07:29,690 Hello testing. 110 00:07:30,200 --> 00:07:35,300 We want to type a string inside double quotes and a semicolon at the end, and then next line will be 111 00:07:35,300 --> 00:07:35,720 returned. 112 00:07:35,720 --> 00:07:36,080 Zero. 113 00:07:36,110 --> 00:07:36,590 That's it. 114 00:07:36,590 --> 00:07:38,020 That's the entire program. 115 00:07:38,030 --> 00:07:43,900 When we run this program, what we want to do is we want to display hello testing to the console. 116 00:07:43,910 --> 00:07:45,140 That's all it's going to do. 117 00:07:45,350 --> 00:07:46,640 I'll save this 118 00:07:49,280 --> 00:07:57,800 under save file at this point on your end, you may want to do view, toggle, minimal view and that'll 119 00:07:57,800 --> 00:07:58,710 display. 120 00:07:58,760 --> 00:07:59,900 Let me do that again. 121 00:08:01,190 --> 00:08:04,700 That will display some buttons and things up here which you might find useful. 122 00:08:05,270 --> 00:08:11,180 I'm not going to do that because it clutters up the screen and I don't want any distractions when I'm 123 00:08:11,180 --> 00:08:11,960 teaching the class. 124 00:08:11,960 --> 00:08:13,970 So I'll toggle that away. 125 00:08:14,630 --> 00:08:19,070 And what I'll do is, rather than click on the buttons, I'll be really explicit as to let's click on 126 00:08:19,070 --> 00:08:21,620 Build, Run, Build, Clean, and so forth. 127 00:08:21,620 --> 00:08:23,720 That way you can see exactly what's going on. 128 00:08:23,720 --> 00:08:27,020 Once you get familiar with the ID, you can use those buttons. 129 00:08:27,590 --> 00:08:28,100 That's it. 130 00:08:28,100 --> 00:08:29,060 So I've saved it. 131 00:08:29,060 --> 00:08:30,590 Now I want to run this. 132 00:08:30,590 --> 00:08:35,630 First thing I want to do is I want to go to build and clean the project. 133 00:08:35,630 --> 00:08:40,909 When we clean a project, we're basically just wiping out everything that's been done in the past except 134 00:08:40,909 --> 00:08:41,750 the source code. 135 00:08:41,750 --> 00:08:47,390 So the project is in a state that's ready to go, so I'm just going to clean it and then I'm going to 136 00:08:47,390 --> 00:08:50,180 come back up to build and I'm going to say Run. 137 00:08:51,080 --> 00:08:55,730 Now it's going to give me an option that says, Would you like to build the active project before executing 138 00:08:55,730 --> 00:08:56,030 it? 139 00:08:56,060 --> 00:08:58,580 Of course I do, because I haven't built it yet in this case. 140 00:08:58,580 --> 00:09:04,370 So I'm going to select, build and execute and that will compile the program and open up a window. 141 00:09:04,370 --> 00:09:06,350 And there's the output right there. 142 00:09:06,350 --> 00:09:06,860 Hello? 143 00:09:06,860 --> 00:09:07,610 Testing. 144 00:09:08,420 --> 00:09:12,770 So this terminal window is running the program that I just wrote. 145 00:09:13,250 --> 00:09:13,940 That's it. 146 00:09:13,940 --> 00:09:15,200 It's a simple as that. 147 00:09:15,770 --> 00:09:17,360 Some things could go wrong, though. 148 00:09:17,360 --> 00:09:23,840 Suppose that you forgot the semicolon here and I'll save it. 149 00:09:23,840 --> 00:09:24,800 And then I'll do the same. 150 00:09:24,800 --> 00:09:27,920 I'll do run, build and execute. 151 00:09:28,340 --> 00:09:31,250 And you can see if I move this window just slightly up. 152 00:09:31,250 --> 00:09:35,000 You can see that I've got a compiler error and this is what compiler errors look like. 153 00:09:35,030 --> 00:09:39,980 You see the red text here and it says error expected a semicolon after an expression. 154 00:09:40,430 --> 00:09:44,600 Also you'll see that little red arrow right here telling you there's just something wrong here. 155 00:09:45,200 --> 00:09:48,140 And basically what you need to do is put a semicolon there. 156 00:09:48,380 --> 00:09:52,040 Just type the program really carefully, exactly like I did it. 157 00:09:52,040 --> 00:09:56,150 You won't have any problems, but you could have things missing like this quote. 158 00:09:56,480 --> 00:09:57,860 This first quote is missing. 159 00:09:57,860 --> 00:09:59,750 This you might have three less than signs. 160 00:09:59,750 --> 00:10:02,540 There's all kinds of little things that could go wrong with the program. 161 00:10:02,540 --> 00:10:10,010 But if you just be very careful, type it in, save it and come back up to build and run, build and 162 00:10:10,010 --> 00:10:10,460 execute. 163 00:10:10,460 --> 00:10:14,630 And you can click on there if you like that we don't have to keep doing it all the time. 164 00:10:15,650 --> 00:10:17,030 And there's the run. 165 00:10:17,660 --> 00:10:18,200 That's it. 166 00:10:18,200 --> 00:10:19,280 We're all set on Mac. 167 00:10:19,280 --> 00:10:24,590 We've installed the command line tools, we've installed code light, we've configured code light and 168 00:10:24,590 --> 00:10:25,640 we're good to go. 169 00:10:26,000 --> 00:10:28,040 Now let's start learning C++.