1 00:00:00,000 --> 00:00:02,074 (bright music) 2 00:00:02,074 --> 00:00:03,366 (logo whooshing) 3 00:00:03,366 --> 00:00:04,980 (keyboard clacking) 4 00:00:04,980 --> 00:00:07,139 Instructor: In this video, we'll run 5 00:00:07,139 --> 00:00:09,120 and configure CodeLite on Mac OS X. 6 00:00:09,120 --> 00:00:11,250 Now we've already installed the compiler tools, 7 00:00:11,250 --> 00:00:12,690 and we've installed CodeLite. 8 00:00:12,690 --> 00:00:13,980 So let's run CodeLite. 9 00:00:13,980 --> 00:00:17,103 We'll come up to Spotlight search and type CodeLite, 10 00:00:18,180 --> 00:00:19,743 and double-click on the icon. 11 00:00:25,350 --> 00:00:26,523 We'll allow it to run. 12 00:00:32,460 --> 00:00:34,200 Now the first time that CodeLite runs, 13 00:00:34,200 --> 00:00:35,640 a couple of things will happen. 14 00:00:35,640 --> 00:00:38,130 You'll get this small CodeLite window show up, 15 00:00:38,130 --> 00:00:39,880 and then you'll get a setup wizard. 16 00:00:41,070 --> 00:00:42,780 We can just leave that window small, 17 00:00:42,780 --> 00:00:44,100 we'll make it larger in a minute. 18 00:00:44,100 --> 00:00:45,810 It's not really gonna get in our way right now. 19 00:00:45,810 --> 00:00:48,450 What's important is that we run this setup wizard. 20 00:00:48,450 --> 00:00:51,390 If the setup wizard does not start, come up 21 00:00:51,390 --> 00:00:54,243 to CodeLite's menu and go up to help, 22 00:00:55,290 --> 00:00:58,920 and then run the setup wizard and run it manually. 23 00:00:58,920 --> 00:01:01,935 Okay, but here in this case it did pop up. 24 00:01:01,935 --> 00:01:02,985 So let's select next. 25 00:01:05,850 --> 00:01:09,120 CodeLite uses a bunch of plugins to allow support 26 00:01:09,120 --> 00:01:11,550 for PHP and Node and other technologies. 27 00:01:11,550 --> 00:01:13,560 We don't really want all that. 28 00:01:13,560 --> 00:01:15,150 We only want the C++ plugins. 29 00:01:15,150 --> 00:01:18,221 The rest are just gonna clutter up our interface. 30 00:01:18,221 --> 00:01:20,310 So what we can do here is we can press clear 31 00:01:20,310 --> 00:01:23,310 and then just toggle the C++ plugins. 32 00:01:23,310 --> 00:01:26,461 That way only some of these will show up, 33 00:01:26,461 --> 00:01:27,294 which is exactly what we want. 34 00:01:27,294 --> 00:01:29,670 We just want to concentrate on C++. 35 00:01:29,670 --> 00:01:30,873 Select next. 36 00:01:32,400 --> 00:01:35,610 Now we can scan our computer for any installed compilers. 37 00:01:35,610 --> 00:01:37,110 We can press this button here, 38 00:01:38,070 --> 00:01:42,360 and you can see it's found GCC, Clang, and the Cross GCC. 39 00:01:42,360 --> 00:01:43,980 We're gonna use GCC. 40 00:01:43,980 --> 00:01:45,210 They're really the same, 41 00:01:45,210 --> 00:01:49,290 but we'll use GCC here, and press next. 42 00:01:49,290 --> 00:01:51,900 Now the customization of the theme is really up to you. 43 00:01:51,900 --> 00:01:53,580 This is your personal preference. 44 00:01:53,580 --> 00:01:56,790 The Monokai dark theme is real nice and easy on the eyes, 45 00:01:56,790 --> 00:02:00,084 but it doesn't show up too well on video. 46 00:02:00,084 --> 00:02:02,790 So I'm going to select the Classic Eclipse theme, 47 00:02:02,790 --> 00:02:05,130 and select next. 48 00:02:05,130 --> 00:02:07,803 We'll keep these defaults and press finish. 49 00:02:09,870 --> 00:02:13,140 Now what we can do here is we can say save and exit. 50 00:02:13,140 --> 00:02:14,460 You wanna be sure that you save, 51 00:02:14,460 --> 00:02:16,473 so we can save the changes we've made, 52 00:02:19,890 --> 00:02:21,513 and we can run CodeLite again. 53 00:02:30,690 --> 00:02:32,340 Okay, so this time I'm gonna make this window 54 00:02:32,340 --> 00:02:33,183 nice and big. 55 00:02:35,940 --> 00:02:37,410 And we've got a couple of options 56 00:02:37,410 --> 00:02:38,670 that we still need to configure. 57 00:02:38,670 --> 00:02:42,000 But before we do that, we need to create a workspace. 58 00:02:42,000 --> 00:02:45,990 You can create a workspace by clicking this button here, 59 00:02:45,990 --> 00:02:49,503 or by coming up to file, new workspace. 60 00:02:50,344 --> 00:02:51,180 Either place works fine. 61 00:02:51,180 --> 00:02:53,160 A workplace is just an area 62 00:02:53,160 --> 00:02:55,590 where we can have our C++ projects. 63 00:02:55,590 --> 00:02:58,140 So we can have multiple projects in a workspace. 64 00:02:58,140 --> 00:03:00,990 So I'm gonna select new workspace, 65 00:03:00,990 --> 00:03:03,420 and the workspace name could be anything you like. 66 00:03:03,420 --> 00:03:05,763 I'm gonna say CPP workspace. 67 00:03:07,350 --> 00:03:10,620 Don't use any spaces here, just keep it all together. 68 00:03:10,620 --> 00:03:12,480 And I want to create the workspace 69 00:03:12,480 --> 00:03:15,720 under a separate directory so I can keep my files organized. 70 00:03:15,720 --> 00:03:18,240 I'll select okay, and you can see 71 00:03:18,240 --> 00:03:21,600 that it's created the workspace over here on the left pane. 72 00:03:21,600 --> 00:03:24,060 Now we need to create a C++ project. 73 00:03:24,060 --> 00:03:29,060 So you can right click on that, and select new project, 74 00:03:29,250 --> 00:03:31,050 or you can select the workspace, 75 00:03:31,050 --> 00:03:33,630 and then come up to file, new project. 76 00:03:33,630 --> 00:03:34,463 Either way. 77 00:03:36,660 --> 00:03:38,640 Now we've got some options. 78 00:03:38,640 --> 00:03:41,283 We're going to create console project, 79 00:03:42,360 --> 00:03:46,950 and simple executable g++ right here. 80 00:03:46,950 --> 00:03:49,260 And that's the compiler we're going to use. 81 00:03:49,260 --> 00:03:52,800 And we'll select next, the project name. 82 00:03:52,800 --> 00:03:54,840 Again, don't use any spaces here. 83 00:03:54,840 --> 00:03:56,013 Just create your name, 84 00:03:57,586 --> 00:03:59,790 the name for your project, whatever you'd like. 85 00:03:59,790 --> 00:04:01,650 Again, I'm going to create a separate directory 86 00:04:01,650 --> 00:04:03,753 for each project, and I'll select next. 87 00:04:06,030 --> 00:04:09,540 As far as the compiler, we want to use the GCC compiler 88 00:04:09,540 --> 00:04:12,000 but the debugger, we don't want to use the GNU debugger, 89 00:04:12,000 --> 00:04:16,110 we want to use the LLDB debugger, that's the Apple debugger. 90 00:04:16,110 --> 00:04:18,149 We'll select finish. 91 00:04:18,149 --> 00:04:19,560 And you can see over here on the left 92 00:04:19,560 --> 00:04:21,536 that we've created a project called Test1, 93 00:04:21,536 --> 00:04:23,400 and it's got a source directory, 94 00:04:23,400 --> 00:04:25,800 and it's got a file there called main cpp. 95 00:04:25,800 --> 00:04:27,720 Now, before we run that file, 96 00:04:27,720 --> 00:04:30,120 there's a couple of things that we need to set up. 97 00:04:30,120 --> 00:04:31,980 First click on the project. 98 00:04:31,980 --> 00:04:34,620 In this case Test1, right click, 99 00:04:34,620 --> 00:04:37,863 and then come down to settings and select that. 100 00:04:39,180 --> 00:04:40,650 Then down here toward the bottom 101 00:04:40,650 --> 00:04:42,960 where you see global settings, 102 00:04:42,960 --> 00:04:46,920 come up to compiler options and select the right side. 103 00:04:46,920 --> 00:04:48,540 And then you'll see this little button right here 104 00:04:48,540 --> 00:04:49,560 with the three dots. 105 00:04:49,560 --> 00:04:50,493 Select that. 106 00:04:51,510 --> 00:04:52,710 And what we want to do here is 107 00:04:52,710 --> 00:04:54,810 we want to check a couple of options. 108 00:04:54,810 --> 00:04:55,860 I'm gonna scroll all the way up, 109 00:04:55,860 --> 00:04:59,073 and I wanna select enable all compiler warnings, Wall, 110 00:05:00,330 --> 00:05:03,330 and I wanna enable C++ 14 features. 111 00:05:03,330 --> 00:05:06,120 That's the latest standard, that's modern C++. 112 00:05:06,120 --> 00:05:07,920 Wanna make sure that that's enabled. 113 00:05:09,210 --> 00:05:10,350 And this guy doesn't come on, 114 00:05:10,350 --> 00:05:11,970 but you can see that it is there. 115 00:05:11,970 --> 00:05:14,010 Sometimes it doesn't check on. 116 00:05:14,010 --> 00:05:15,660 You can see that the command line is correct. 117 00:05:15,660 --> 00:05:20,070 So just click okay, I'll apply and click okay. 118 00:05:20,070 --> 00:05:20,903 Perfect. 119 00:05:20,903 --> 00:05:24,390 Now go to the workspace, select it, 120 00:05:24,390 --> 00:05:27,423 right click on it, and come down to workspace settings. 121 00:05:29,465 --> 00:05:31,080 And you'll see we have environment and code completion. 122 00:05:31,080 --> 00:05:32,583 Select code completion, 123 00:05:33,570 --> 00:05:38,020 and check the enable C++ 14 standard. 124 00:05:38,020 --> 00:05:38,853 Okay. 125 00:05:38,853 --> 00:05:41,460 The integrated development environments use code completion. 126 00:05:41,460 --> 00:05:42,930 They try to figure out what you're typing 127 00:05:42,930 --> 00:05:44,940 and what you want to do and where you want to go, 128 00:05:44,940 --> 00:05:47,070 and really help you out with suggestions. 129 00:05:47,070 --> 00:05:50,070 In this case, we're simply telling CodeLite to use 130 00:05:50,070 --> 00:05:53,043 the C++ 14 standard for those suggestions. 131 00:05:53,880 --> 00:05:57,570 I'll click okay, and that's it for the setup. 132 00:05:57,570 --> 00:06:00,783 Now let's modify this C++ file and run it. 133 00:06:01,860 --> 00:06:03,840 Let's double-click on that. 134 00:06:03,840 --> 00:06:06,420 And that font is really small, 135 00:06:06,420 --> 00:06:08,460 so what I'm gonna do is, I'm gonna make it a little larger 136 00:06:08,460 --> 00:06:10,020 so it shows up better on the video. 137 00:06:10,020 --> 00:06:12,120 Most likely you won't have to touch it at all, 138 00:06:12,120 --> 00:06:15,990 but I'm just gonna come to settings, colors, and fonts, 139 00:06:15,990 --> 00:06:20,283 and I'll set the font to let's say 18. 140 00:06:23,748 --> 00:06:27,900 And I'll apply that, and that should be much more readable. 141 00:06:27,900 --> 00:06:29,610 Okay, so now let's modify this file. 142 00:06:29,610 --> 00:06:31,890 This is actually C code, not C++ code. 143 00:06:31,890 --> 00:06:33,663 So let's get rid of all this, 144 00:06:34,620 --> 00:06:37,230 and we'll type a simple C++ program 145 00:06:37,230 --> 00:06:38,970 that'll test our installation. 146 00:06:38,970 --> 00:06:41,250 During this course, I will go in detail 147 00:06:41,250 --> 00:06:43,560 through the anatomy of a C++ program. 148 00:06:43,560 --> 00:06:46,080 And everything that I'll be typing here will be explained. 149 00:06:46,080 --> 00:06:47,790 But for now, just follow along, 150 00:06:47,790 --> 00:06:50,640 type along, to make sure we've got a clean install. 151 00:06:50,640 --> 00:06:51,810 So the first thing we wanna do is 152 00:06:51,810 --> 00:06:55,530 we wanna type #include, and we wanna put 153 00:06:55,530 --> 00:06:59,103 iostream in angle brackets, and press enter. 154 00:07:00,030 --> 00:07:04,173 Then int space main, left paren, right paren. 155 00:07:05,010 --> 00:07:06,903 Then we wanna open up a left curly. 156 00:07:08,040 --> 00:07:11,130 And you can see that the IDE has closed it for me. 157 00:07:11,130 --> 00:07:12,450 And then what I wanna do here is I just 158 00:07:12,450 --> 00:07:16,830 wanna say std, two colons, side by side, no spaces, 159 00:07:16,830 --> 00:07:20,640 and then see cout, the insertion operator, 160 00:07:20,640 --> 00:07:23,225 which is two less than signs. 161 00:07:23,225 --> 00:07:25,590 Again, together with no spaces, 162 00:07:25,590 --> 00:07:27,720 and anything you want to type here as far as 163 00:07:27,720 --> 00:07:32,220 hello testing, we wanna type a string inside double quotes 164 00:07:32,220 --> 00:07:34,140 and a semicolon at the end. 165 00:07:34,140 --> 00:07:36,120 And then next line will be return 0. 166 00:07:36,120 --> 00:07:37,602 That's it. 167 00:07:37,602 --> 00:07:38,435 That's the entire program. 168 00:07:38,435 --> 00:07:40,680 When we run this program, what we want to do is 169 00:07:40,680 --> 00:07:43,920 we wanna display hello testing to the console. 170 00:07:43,920 --> 00:07:45,360 That's all it's going to do. 171 00:07:45,360 --> 00:07:50,360 I'll save this under save file. 172 00:07:50,670 --> 00:07:53,583 At this point on your end, you may want to do view, 173 00:07:55,050 --> 00:07:58,800 toggle minimal view, and that'll display, 174 00:07:58,800 --> 00:07:59,850 let me do that again. 175 00:08:01,230 --> 00:08:03,240 That'll display some buttons and things up here 176 00:08:03,240 --> 00:08:05,400 which you might find useful. 177 00:08:05,400 --> 00:08:08,190 I'm not gonna do that 'cause it clutters up the screen, 178 00:08:08,190 --> 00:08:10,920 and I don't want any distractions 179 00:08:10,920 --> 00:08:11,940 when I'm teaching the class. 180 00:08:11,940 --> 00:08:14,730 So I'll toggle that away. 181 00:08:14,730 --> 00:08:16,620 And what I'll do is, rather than click on the buttons, 182 00:08:16,620 --> 00:08:19,650 I'll be really explicit as to let's click on build, 183 00:08:19,650 --> 00:08:21,690 run build, clean, and so forth. 184 00:08:21,690 --> 00:08:23,790 That way you can see exactly what's going on. 185 00:08:23,790 --> 00:08:25,800 Once you get familiar with the IDE, 186 00:08:25,800 --> 00:08:27,630 you can use those buttons. 187 00:08:27,630 --> 00:08:29,142 That's it. 188 00:08:29,142 --> 00:08:30,141 So I've saved it. 189 00:08:30,141 --> 00:08:30,974 Now I wanna run this. 190 00:08:30,974 --> 00:08:33,059 First thing I wanna do is I want to go to build, 191 00:08:34,080 --> 00:08:35,760 and clean the project. 192 00:08:35,760 --> 00:08:38,070 When we clean a project, we're basically just wiping 193 00:08:38,070 --> 00:08:40,559 out everything that's been done in the past, 194 00:08:40,559 --> 00:08:41,763 except the source code. 195 00:08:42,623 --> 00:08:44,280 So the project is in a state that's ready to go. 196 00:08:44,280 --> 00:08:45,630 So I'm just gonna clean it. 197 00:08:46,920 --> 00:08:48,930 And then I'm gonna come back up to build, 198 00:08:48,930 --> 00:08:50,180 and I'm going to say run. 199 00:08:51,060 --> 00:08:53,160 Now it's gonna give me an option that says 200 00:08:53,160 --> 00:08:54,810 would you like to build the active project 201 00:08:54,810 --> 00:08:56,100 before executing it? 202 00:08:56,100 --> 00:08:58,650 Of course I do, because I haven't built it yet in this case. 203 00:08:58,650 --> 00:09:01,110 So I'm gonna select build and execute, 204 00:09:01,110 --> 00:09:04,560 and that will compile the program and open up a window. 205 00:09:04,560 --> 00:09:06,390 And there's the output right there. 206 00:09:06,390 --> 00:09:07,563 Hello, testing. 207 00:09:08,520 --> 00:09:11,730 So this terminal window is running the program 208 00:09:11,730 --> 00:09:13,350 that I just wrote. 209 00:09:13,350 --> 00:09:14,822 That's it. 210 00:09:14,822 --> 00:09:15,750 It's as simple as that. 211 00:09:15,750 --> 00:09:17,490 Some things could go wrong though. 212 00:09:17,490 --> 00:09:21,243 Suppose that you forgot this semicolon here, 213 00:09:22,950 --> 00:09:24,810 and I'll save it and then I'll do the same. 214 00:09:24,810 --> 00:09:28,470 I'll do run, build, and execute. 215 00:09:28,470 --> 00:09:31,350 And you can see if I move this window just slightly up, 216 00:09:31,350 --> 00:09:33,150 you can see that I've got a compiler error. 217 00:09:33,150 --> 00:09:35,100 And this is what compiler errors look like. 218 00:09:35,100 --> 00:09:36,630 You see the red text here, 219 00:09:36,630 --> 00:09:40,500 and it says error, expected a semicolon after an expression. 220 00:09:40,500 --> 00:09:42,930 Also, you'll see that little red arrow right here 221 00:09:42,930 --> 00:09:45,360 telling you that there's something wrong here. 222 00:09:45,360 --> 00:09:48,420 And basically what you need to do is put a semicolon there. 223 00:09:48,420 --> 00:09:52,050 Just type the program really carefully, exactly like I did. 224 00:09:52,050 --> 00:09:54,273 You won't have any problems, 225 00:09:54,273 --> 00:09:55,106 but you know, you could have things missing, 226 00:09:55,106 --> 00:09:58,140 like this quote might, this first quote is missing, 227 00:09:58,140 --> 00:09:59,790 you might have three less than signs. 228 00:09:59,790 --> 00:10:00,990 There's all kinds of little things 229 00:10:00,990 --> 00:10:02,640 that could go wrong with the program, 230 00:10:02,640 --> 00:10:06,210 but if you just be very careful, type it in, save it, 231 00:10:06,210 --> 00:10:10,470 and come back up to build and run, build and execute. 232 00:10:10,470 --> 00:10:12,900 And you can click on there if you like. 233 00:10:12,900 --> 00:10:15,113 That way you don't have to keep doing it all the time. 234 00:10:16,529 --> 00:10:17,700 And there's the run. 235 00:10:17,700 --> 00:10:19,190 That's it. 236 00:10:19,190 --> 00:10:20,193 We're all set on Mac. 237 00:10:20,193 --> 00:10:21,026 We've installed the command line tools, 238 00:10:21,026 --> 00:10:24,330 we've installed CodeLite, we've configured CodeLite, 239 00:10:24,330 --> 00:10:26,100 and we're good to go. 240 00:10:26,100 --> 00:10:28,393 Now let's start learning C++.