1 00:00:00,000 --> 00:00:02,387 (bright music) 2 00:00:02,387 --> 00:00:05,460 (keyboard clicking) 3 00:00:05,460 --> 00:00:06,293 Frank: In this video, 4 00:00:06,293 --> 00:00:08,970 we're going to configure the CodeLite IDE 5 00:00:08,970 --> 00:00:10,620 that we just installed 6 00:00:10,620 --> 00:00:13,560 to work on our Windows system with C++. 7 00:00:13,560 --> 00:00:15,930 So the first thing we wanna do is we wanna start CodeLite, 8 00:00:15,930 --> 00:00:18,750 so I'm just gonna double click on the icon. 9 00:00:18,750 --> 00:00:21,030 And the first time that you run CodeLite, 10 00:00:21,030 --> 00:00:24,483 you'll probably get a little setup wizard popup. 11 00:00:25,410 --> 00:00:26,550 And here it is. 12 00:00:26,550 --> 00:00:28,207 You may also get a window that says, 13 00:00:28,207 --> 00:00:30,000 "Do you want to update to the latest version," 14 00:00:30,000 --> 00:00:31,260 which you can certainly do. 15 00:00:31,260 --> 00:00:33,450 I'm gonna cancel for this video. 16 00:00:33,450 --> 00:00:35,220 And here's the setup wizard. 17 00:00:35,220 --> 00:00:37,920 Now it's important that you run through this setup wizard. 18 00:00:37,920 --> 00:00:40,680 If this does not show up for the first time, 19 00:00:40,680 --> 00:00:43,380 you can always find it up here, you can select help, 20 00:00:43,380 --> 00:00:46,110 and then you can run the setup wizard here. 21 00:00:46,110 --> 00:00:47,820 But in this case it does show up. 22 00:00:47,820 --> 00:00:48,870 So I'm gonna go through this, 23 00:00:48,870 --> 00:00:50,670 and you only have to do this one time. 24 00:00:50,670 --> 00:00:51,993 I'm gonna select next. 25 00:00:54,150 --> 00:00:56,280 Now here, the way that CodeLite works 26 00:00:56,280 --> 00:00:58,713 is it uses a lot of plugins to support PHP, 27 00:00:59,586 --> 00:01:01,260 C, C++ and so forth. 28 00:01:01,260 --> 00:01:03,810 We only care about C++ in this case. 29 00:01:03,810 --> 00:01:07,020 So what we want to do is we want to clear these plugins. 30 00:01:07,020 --> 00:01:09,270 So you can see all the check marks are gone. 31 00:01:09,270 --> 00:01:12,510 And then we wanna toggle the C++ plugins only. 32 00:01:12,510 --> 00:01:17,510 So I'm gonna select that until only the C++ ones show up. 33 00:01:18,120 --> 00:01:19,740 Okay? So that's what we need to do. 34 00:01:19,740 --> 00:01:21,630 Just make sure that not all of them are set up, 35 00:01:21,630 --> 00:01:24,060 just some of them, you can use the toggle to do it. 36 00:01:24,060 --> 00:01:25,023 I'll select next. 37 00:01:26,550 --> 00:01:28,110 Now we wanna set up the compiler. 38 00:01:28,110 --> 00:01:30,600 Now remember, if you've already installed 39 00:01:30,600 --> 00:01:33,480 the MinGW compiler, then you can just click scan. 40 00:01:33,480 --> 00:01:35,790 If you haven't, go back to the video and install it. 41 00:01:35,790 --> 00:01:37,500 I wouldn't install it from this option, 42 00:01:37,500 --> 00:01:41,190 'cause it installs an older version of the MinGW compiler. 43 00:01:41,190 --> 00:01:44,670 So I'm going to scan, and it should find it, there it is. 44 00:01:44,670 --> 00:01:47,613 So I wanna select it, and press next. 45 00:01:49,380 --> 00:01:51,990 Now here you can customize the colors to whatever you like. 46 00:01:51,990 --> 00:01:55,860 This dark Monokai theme is kind of nice on the vision, 47 00:01:55,860 --> 00:01:57,540 it's not so hard on your eyes. 48 00:01:57,540 --> 00:02:00,690 For the video I'm going to choose the classic Eclipse look. 49 00:02:00,690 --> 00:02:03,000 That way I think it shows up a little better on video. 50 00:02:03,000 --> 00:02:04,293 So I'll select next. 51 00:02:05,790 --> 00:02:09,393 We'll leave these defaults as-is, and we'll press finish. 52 00:02:11,220 --> 00:02:13,710 Now at this point you want to save and exit. 53 00:02:13,710 --> 00:02:15,870 It's gonna ask you this every time you make a change, 54 00:02:15,870 --> 00:02:16,920 and it gets pretty annoying. 55 00:02:16,920 --> 00:02:17,753 So I'm just gonna say, 56 00:02:17,753 --> 00:02:19,980 remember my answer and don't ask me again. 57 00:02:19,980 --> 00:02:22,740 And every time I make a change, I wanna save and exit, 58 00:02:22,740 --> 00:02:23,840 so I'll save and exit. 59 00:02:27,090 --> 00:02:29,310 Okay, so it saves it, and it opens it up again, 60 00:02:29,310 --> 00:02:32,670 and now the settings that I set were applied. 61 00:02:32,670 --> 00:02:35,250 And again, I'll cancel the new download here. 62 00:02:35,250 --> 00:02:37,473 Okay, so let me make this full screen here. 63 00:02:38,790 --> 00:02:39,960 And as I mentioned before, 64 00:02:39,960 --> 00:02:42,060 if that setup wizard does not show up, 65 00:02:42,060 --> 00:02:43,710 you can start it here. 66 00:02:43,710 --> 00:02:45,063 Run the setup wizard. 67 00:02:46,410 --> 00:02:48,630 Okay, so now, what we want to do 68 00:02:48,630 --> 00:02:51,060 is we wanna create a new workspace. 69 00:02:51,060 --> 00:02:52,980 And once we create the new workspace, 70 00:02:52,980 --> 00:02:54,630 we'll have a couple settings to do, 71 00:02:54,630 --> 00:02:56,490 and then once that's done, it'll be all set. 72 00:02:56,490 --> 00:02:58,350 So let's create a new workspace. 73 00:02:58,350 --> 00:03:00,660 A workspace is basically an area 74 00:03:00,660 --> 00:03:03,570 where you can have different C++ projects in. 75 00:03:03,570 --> 00:03:05,880 So the first thing we wanna do is create a new workspace. 76 00:03:05,880 --> 00:03:06,900 I'll select that. 77 00:03:06,900 --> 00:03:10,770 You can also say file, new workspace. 78 00:03:10,770 --> 00:03:12,570 Okay, so I'll do it right here. 79 00:03:12,570 --> 00:03:14,610 And it's gonna ask me for the name of the workspace. 80 00:03:14,610 --> 00:03:18,033 So I'll just say, CPP Workspace. 81 00:03:19,110 --> 00:03:22,634 You could do this whatever you like, if you want to have, 82 00:03:22,634 --> 00:03:25,320 you know, a workspace for all the section one exercises, 83 00:03:25,320 --> 00:03:27,510 section two, section three, or whatever you like, 84 00:03:27,510 --> 00:03:29,490 whatever makes sense for you. 85 00:03:29,490 --> 00:03:32,100 I'm going to put it in my documents folder, 86 00:03:32,100 --> 00:03:34,770 and I wanna create the workspace under a separate directory, 87 00:03:34,770 --> 00:03:37,320 that just helps me organize my files. 88 00:03:37,320 --> 00:03:38,463 I'll select okay. 89 00:03:40,110 --> 00:03:42,030 Good, now you can see here on the left pane 90 00:03:42,030 --> 00:03:44,400 on my workspace view, I've got a workspace. 91 00:03:44,400 --> 00:03:47,220 Now the workspace in and of itself isn't real useful. 92 00:03:47,220 --> 00:03:50,130 I need to create a project within the workspace. 93 00:03:50,130 --> 00:03:54,960 So I can right click on workspace and say new project. 94 00:03:54,960 --> 00:03:57,840 So I'll do that and I'll select new project. 95 00:03:57,840 --> 00:03:59,973 At this point, we've got some options. 96 00:04:01,140 --> 00:04:04,050 We're going to select the console option, 97 00:04:04,050 --> 00:04:07,650 and then simple executable G++. 98 00:04:07,650 --> 00:04:10,830 That's basically the C++ compiler. 99 00:04:10,830 --> 00:04:13,830 It's called G++ because it's from GNU. 100 00:04:13,830 --> 00:04:16,470 So I'll select that next. 101 00:04:16,470 --> 00:04:18,029 And then you give your project a name. 102 00:04:18,029 --> 00:04:20,010 This could be again, any name you like. 103 00:04:20,010 --> 00:04:23,340 Avoid spaces just to be safe, just simple name. 104 00:04:23,340 --> 00:04:26,403 So I'll say Test1, let's say. 105 00:04:27,450 --> 00:04:29,550 And again, I wanna create a project under, 106 00:04:29,550 --> 00:04:31,350 in a separate directory. 107 00:04:31,350 --> 00:04:32,493 I'll press next. 108 00:04:33,600 --> 00:04:35,160 Here you can choose the compiler, 109 00:04:35,160 --> 00:04:37,350 it's probably already chosen it for you. 110 00:04:37,350 --> 00:04:39,210 If you've got multiple compilers, 111 00:04:39,210 --> 00:04:42,720 you can set individual compilers on a per-project level, 112 00:04:42,720 --> 00:04:45,060 but we're using the MinGW compiler, 113 00:04:45,060 --> 00:04:47,520 and we're using the GNU debugger. 114 00:04:47,520 --> 00:04:51,630 The build system will be default, and select finish. 115 00:04:51,630 --> 00:04:53,850 So it's gone off and created a new project, 116 00:04:53,850 --> 00:04:56,490 you can see it here on the left side, it's called Test One. 117 00:04:56,490 --> 00:04:58,620 And as I explode these, 118 00:04:58,620 --> 00:05:01,620 you can see that there's my main CPP file. 119 00:05:01,620 --> 00:05:04,830 That's the program that it's created for me by default. 120 00:05:04,830 --> 00:05:08,760 The .CPP extension means that it's a C++ file. 121 00:05:08,760 --> 00:05:10,890 I'm going to double click on that, 122 00:05:10,890 --> 00:05:13,560 and you can see my font is pretty small here, 123 00:05:13,560 --> 00:05:14,670 'cause I just installed this. 124 00:05:14,670 --> 00:05:16,320 Let me increase my font. 125 00:05:16,320 --> 00:05:17,850 You may not have to do this on your end, 126 00:05:17,850 --> 00:05:20,160 but it's gonna show up better on video if I do it. 127 00:05:20,160 --> 00:05:23,010 So I'm gonna go to settings, colors and fonts, 128 00:05:23,010 --> 00:05:25,983 and I'll just set it to at 16, I think should be nice. 129 00:05:27,240 --> 00:05:28,710 Apply, okay, there we go, 130 00:05:28,710 --> 00:05:30,570 that way it's much easier for you to see. 131 00:05:30,570 --> 00:05:33,720 Now what we want to do is we want to delete all this. 132 00:05:33,720 --> 00:05:36,360 This is actually C code, not C++ code. 133 00:05:36,360 --> 00:05:37,380 So let's delete all that 134 00:05:37,380 --> 00:05:40,860 and let's write a real simple test from scratch. 135 00:05:40,860 --> 00:05:45,860 So the first thing we'll do is we'll include iostream. 136 00:05:47,430 --> 00:05:49,830 This allows us to do input and output. 137 00:05:49,830 --> 00:05:51,000 And we will talk much more 138 00:05:51,000 --> 00:05:54,060 about what these include directives mean in a future video. 139 00:05:54,060 --> 00:05:55,950 In this example, just type along, 140 00:05:55,950 --> 00:05:58,170 and make sure that the environment is working. 141 00:05:58,170 --> 00:06:00,360 So you want to say pound include, 142 00:06:00,360 --> 00:06:03,120 and iostream in angle brackets. 143 00:06:03,120 --> 00:06:05,550 Then we want to say int, space, main, 144 00:06:05,550 --> 00:06:07,173 this is our main function. 145 00:06:08,310 --> 00:06:09,153 Two parens, 146 00:06:10,200 --> 00:06:14,700 and we'll create a couple of curlies, curly braces. 147 00:06:14,700 --> 00:06:19,700 Then in here all we're gonna say is std, colon colon c-out. 148 00:06:19,830 --> 00:06:23,130 The insertion operator, which is two less than signs, 149 00:06:23,130 --> 00:06:27,720 followed by "Hello testing" or anything you like. 150 00:06:27,720 --> 00:06:29,610 And then a semicolon at the end, 151 00:06:29,610 --> 00:06:31,830 and then finally return zero. 152 00:06:31,830 --> 00:06:34,260 That's it. That's a simple test. 153 00:06:34,260 --> 00:06:35,940 Again, there'll be a separate video 154 00:06:35,940 --> 00:06:38,670 where I go over the anatomy of a C++ program 155 00:06:38,670 --> 00:06:40,530 and we'll go over all this in detail. 156 00:06:40,530 --> 00:06:43,230 So in this case, again, we're including iostream, 157 00:06:43,230 --> 00:06:45,150 we've got our main function, 158 00:06:45,150 --> 00:06:48,270 and we're printing "Hello testing" to the screen. 159 00:06:48,270 --> 00:06:51,600 We're returning zero, which means program successful. 160 00:06:51,600 --> 00:06:53,670 Okay, I'm going to save this. 161 00:06:53,670 --> 00:06:56,130 And I'm not gonna do this on the videos, 162 00:06:56,130 --> 00:06:57,810 but you can certainly do this at home. 163 00:06:57,810 --> 00:07:01,833 If you come up to view, and you can toggle the minimal view. 164 00:07:02,790 --> 00:07:05,547 When you do that, you'll get some icons up here, 165 00:07:05,547 --> 00:07:07,980 and you can use these icons to build and save, 166 00:07:07,980 --> 00:07:10,020 for example, that's the save right there. 167 00:07:10,020 --> 00:07:11,160 I'm not gonna do that 'cause I want 168 00:07:11,160 --> 00:07:14,160 as much screen real estate as possible on the videos. 169 00:07:14,160 --> 00:07:17,043 So I'll just toggle that off. 170 00:07:18,120 --> 00:07:20,103 Okay, so I'm going to file, save. 171 00:07:22,440 --> 00:07:25,290 And at this point we're ready to run the program, 172 00:07:25,290 --> 00:07:27,030 but we need to make a couple of changes 173 00:07:27,030 --> 00:07:30,477 just because we want to use modern C++. 174 00:07:30,477 --> 00:07:33,480 So what we can do is we can click on the project, 175 00:07:33,480 --> 00:07:36,360 Test1 in this example, and I'll right click, 176 00:07:36,360 --> 00:07:38,640 and down at the bottom you'll see settings. 177 00:07:38,640 --> 00:07:40,143 So we'll select settings. 178 00:07:41,220 --> 00:07:43,440 And you can see right down here at the bottom 179 00:07:43,440 --> 00:07:45,990 where it says global settings, I wanna select that. 180 00:07:48,240 --> 00:07:51,540 And where it says C++ compiler options, 181 00:07:51,540 --> 00:07:53,190 you can click right in there, 182 00:07:53,190 --> 00:07:54,870 and then you'll see these three little dots 183 00:07:54,870 --> 00:07:56,670 here on the button, so it gives us another menu, 184 00:07:56,670 --> 00:07:57,933 so you can select that. 185 00:07:58,800 --> 00:08:00,840 And we wanna make sure that a couple of things are set. 186 00:08:00,840 --> 00:08:05,580 We want to be sure that C++ 14 is checked. 187 00:08:05,580 --> 00:08:08,820 That means we're using the latest version of the standard, 188 00:08:08,820 --> 00:08:11,190 which is Modern C++. 189 00:08:11,190 --> 00:08:13,890 We also wanna be sure that the WALL, 190 00:08:13,890 --> 00:08:16,083 all warnings is checked. 191 00:08:17,790 --> 00:08:19,950 Okay, so that's it, for now that'll be fine, 192 00:08:19,950 --> 00:08:21,063 we'll select okay. 193 00:08:24,120 --> 00:08:28,773 And we'll apply, and okay, perfect. 194 00:08:29,850 --> 00:08:32,789 Now I also want to click on the workspace itself, 195 00:08:32,789 --> 00:08:34,740 and right click on that. 196 00:08:34,740 --> 00:08:38,370 And come down to workspace settings and select that. 197 00:08:38,370 --> 00:08:40,799 And when you come to code completion, 198 00:08:40,799 --> 00:08:44,313 you wanna be sure that C++ 14 Standard is enabled. 199 00:08:45,300 --> 00:08:48,180 Code completion is something that the IDE does. 200 00:08:48,180 --> 00:08:50,460 As you type, it's trying to figure out what you want to do 201 00:08:50,460 --> 00:08:53,040 and help you out so you don't have to do a lot of typing. 202 00:08:53,040 --> 00:08:54,958 And in this case, we want to tell it to use 203 00:08:54,958 --> 00:08:59,340 the C++ 14 standard when it's trying to figure things out. 204 00:08:59,340 --> 00:09:01,380 So I'll select okay. 205 00:09:01,380 --> 00:09:04,410 Now at this point we should be ready to try this out. 206 00:09:04,410 --> 00:09:05,820 So I'm gonna expand this little window 207 00:09:05,820 --> 00:09:07,350 down here at the bottom, 208 00:09:07,350 --> 00:09:10,110 and I'm gonna come up to where it says build, 209 00:09:10,110 --> 00:09:12,243 and then we'll select clean project. 210 00:09:14,130 --> 00:09:17,520 Then we'll go back to build, and just say run. 211 00:09:17,520 --> 00:09:19,410 At this point it's gonna say, what do you want to do? 212 00:09:19,410 --> 00:09:22,110 Do you just wanna run it or you wanna build it and run it? 213 00:09:22,110 --> 00:09:23,640 In this case, I wanna build it and run it, 214 00:09:23,640 --> 00:09:25,170 and I'll talk more about the workflow 215 00:09:25,170 --> 00:09:28,350 that's used for cleaning and compiling and so forth 216 00:09:28,350 --> 00:09:30,900 a little bit later on in the course. 217 00:09:30,900 --> 00:09:33,330 So in this case, I wanna say build and execute, 218 00:09:33,330 --> 00:09:35,550 and it will compile and run the program. 219 00:09:35,550 --> 00:09:37,200 If there are no errors, it'll run, 220 00:09:37,200 --> 00:09:39,577 you'll get a window pop up with the output, 221 00:09:39,577 --> 00:09:41,100 "Hello testing" in there. 222 00:09:41,100 --> 00:09:42,090 If there are errors, 223 00:09:42,090 --> 00:09:43,470 let me show you what they might look like 224 00:09:43,470 --> 00:09:44,920 just in case you do see them. 225 00:09:45,780 --> 00:09:49,050 Suppose I forget that semicolon at the end there. 226 00:09:49,050 --> 00:09:53,700 And I'm going to say build, run, build and execute. 227 00:09:53,700 --> 00:09:56,677 And you can see this red down here that says, 228 00:09:56,677 --> 00:10:00,060 "Error, expected a semicolon before the return." 229 00:10:00,060 --> 00:10:02,416 You also get a red error here. 230 00:10:02,416 --> 00:10:05,130 And it says again, semicolon expected. 231 00:10:05,130 --> 00:10:09,210 So basically you just put the semicolon in there, save it, 232 00:10:09,210 --> 00:10:13,410 and then go back up to build and run, build and execute, 233 00:10:13,410 --> 00:10:15,180 you can click on here for it to remember 234 00:10:15,180 --> 00:10:17,490 to always build and execute or just execute. 235 00:10:17,490 --> 00:10:18,900 Again, don't do that yet. 236 00:10:18,900 --> 00:10:20,430 We'll do that as the course progresses 237 00:10:20,430 --> 00:10:22,740 and I'll show you the different workflows we can use. 238 00:10:22,740 --> 00:10:24,003 So build and execute. 239 00:10:24,900 --> 00:10:25,860 There we go. 240 00:10:25,860 --> 00:10:29,160 Now, if at this point you get an error that says 241 00:10:29,160 --> 00:10:33,660 that some DLL can't be found, then what you want to do is, 242 00:10:33,660 --> 00:10:37,560 you want to go back to the project, right click, 243 00:10:37,560 --> 00:10:39,780 and go down to settings. 244 00:10:39,780 --> 00:10:41,190 And remember, you only have to do this 245 00:10:41,190 --> 00:10:44,130 if you get some kind of runtime error that says 246 00:10:44,130 --> 00:10:47,070 some CPP DLL file is not found. 247 00:10:47,070 --> 00:10:48,960 And go to global settings. 248 00:10:48,960 --> 00:10:50,250 And then what you wanna do is you want to go 249 00:10:50,250 --> 00:10:52,740 to the linker options. 250 00:10:52,740 --> 00:10:55,740 And just select right on there and click that little button. 251 00:10:56,580 --> 00:10:58,140 And down here at the bottom, 252 00:10:58,140 --> 00:11:00,420 what you wanna do is you just want add a couple of lines. 253 00:11:00,420 --> 00:11:05,420 You could say dash, static, dash libGCC, 254 00:11:06,972 --> 00:11:08,310 and then press enter, 255 00:11:08,310 --> 00:11:13,310 and that dash static, dash libSTD, C++. 256 00:11:16,230 --> 00:11:18,420 Okay, so what'll happen here is now the linker 257 00:11:18,420 --> 00:11:20,670 is going to statically link the files, 258 00:11:20,670 --> 00:11:24,600 and not have to use dynamically linked libraries or DLLs. 259 00:11:24,600 --> 00:11:27,270 Again, you only have to do this if you get that error. 260 00:11:27,270 --> 00:11:28,710 If you don't get the error, you can do it also, 261 00:11:28,710 --> 00:11:33,120 and it's not gonna hurt, but I'll select okay, apply, 262 00:11:33,120 --> 00:11:35,343 and let's do a build. 263 00:11:36,600 --> 00:11:38,190 Rebuild, let's do a clean first, 264 00:11:38,190 --> 00:11:39,930 whenever you change any kind of settings, 265 00:11:39,930 --> 00:11:41,040 you want to clean the project, 266 00:11:41,040 --> 00:11:42,900 which really just cleans everything up 267 00:11:42,900 --> 00:11:44,430 and gives you a starting place. 268 00:11:44,430 --> 00:11:47,880 So we'll clean the project, and then we'll just say run, 269 00:11:47,880 --> 00:11:48,750 build and execute. 270 00:11:48,750 --> 00:11:50,670 In this case, it's gonna statically link it, 271 00:11:50,670 --> 00:11:52,470 which is just as good. 272 00:11:52,470 --> 00:11:55,020 And hello testing. we're all set. 273 00:11:55,020 --> 00:11:58,380 At this point we've got a good install, it's configured, 274 00:11:58,380 --> 00:12:01,993 and we're ready to use CodeLite to start learning C++.