1 00:00:05,440 --> 00:00:11,620 In this video, we're going to configure the code light ID that we just installed to work on our Windows 2 00:00:11,620 --> 00:00:13,420 system with C++. 3 00:00:13,420 --> 00:00:15,940 So the first thing we want to do is we want to start code light. 4 00:00:15,940 --> 00:00:17,830 So I'm just going to double click on the icon. 5 00:00:18,580 --> 00:00:25,960 And the first time that you run code light, you'll probably get a little setup wizard pop up and here 6 00:00:25,960 --> 00:00:26,290 it is. 7 00:00:26,290 --> 00:00:30,880 You may also get a window that says you want to update to the latest version, which you can certainly 8 00:00:30,880 --> 00:00:31,230 do. 9 00:00:31,240 --> 00:00:34,930 I'm going to cancel for this video and here's the setup wizard. 10 00:00:35,050 --> 00:00:37,930 Now, it's important that you run through this setup wizard. 11 00:00:37,930 --> 00:00:42,040 If this does not show up for the first time, you can always find it up here. 12 00:00:42,040 --> 00:00:45,940 You can select help and then you can run the setup wizard here. 13 00:00:45,940 --> 00:00:47,710 But in this case it does show up. 14 00:00:47,710 --> 00:00:50,560 So I'm going to go through this and you only have to do this one time. 15 00:00:50,560 --> 00:00:51,970 I'm going to select next. 16 00:00:54,040 --> 00:01:00,640 Now here, the way that code light works is it uses a lot of plug ins to support PHP, C, C++ and so 17 00:01:00,640 --> 00:01:01,120 forth. 18 00:01:01,120 --> 00:01:03,670 We only care about C++ in this case. 19 00:01:03,670 --> 00:01:08,890 So what we want to do is we want to clear these plug ins so you can see all the checkmarks are gone 20 00:01:09,130 --> 00:01:12,400 and then we want to toggle the C++ plug ins only. 21 00:01:12,400 --> 00:01:17,590 So I'm going to select that until only the C++ ones show up. 22 00:01:18,610 --> 00:01:19,750 So that's what we need to do. 23 00:01:19,750 --> 00:01:22,300 Just make sure that not all of them are set up, just some of them. 24 00:01:22,300 --> 00:01:23,860 You can use the toggle to do it. 25 00:01:24,100 --> 00:01:25,270 I'll select next. 26 00:01:26,440 --> 00:01:28,120 Now we want to set up the compiler. 27 00:01:28,120 --> 00:01:33,490 Now, remember, if you've already installed the GW compiler, then you can just click scan. 28 00:01:33,490 --> 00:01:35,740 If you have it, go back to the video and install it. 29 00:01:35,740 --> 00:01:40,690 I wouldn't install it from this option because it installs an older version of the GW compiler. 30 00:01:41,080 --> 00:01:43,960 So I'm going to scan and it should find it. 31 00:01:43,960 --> 00:01:44,620 There it is. 32 00:01:44,620 --> 00:01:47,560 So I want to select it and press next. 33 00:01:49,270 --> 00:01:51,910 Now here you can customize the colors to whatever you like. 34 00:01:51,910 --> 00:01:54,280 This dark monarchy theme. 35 00:01:54,280 --> 00:01:55,870 It's kind of nice on the on the vision. 36 00:01:55,870 --> 00:01:57,190 It's not so hard on your eyes. 37 00:01:57,190 --> 00:01:59,980 But for the video, I'm going to choose the classic eclipse. 38 00:01:59,980 --> 00:02:07,330 Look that way I think it shows up a little better on video so I'll select next will leave these defaults 39 00:02:07,330 --> 00:02:13,690 as is and we'll press finish now at this point you want to save an exit. 40 00:02:13,690 --> 00:02:16,870 It's going to ask you this every time you make a change and it gets pretty annoying. 41 00:02:16,870 --> 00:02:19,780 So I'm just going to say remember my answer and don't ask me again. 42 00:02:19,780 --> 00:02:22,750 And every time I make a change, I want to save an exit. 43 00:02:22,750 --> 00:02:23,860 So I'll save an exit. 44 00:02:27,370 --> 00:02:29,320 So it saves it and it opens it up again. 45 00:02:29,320 --> 00:02:32,140 And now these settings that I set were applied. 46 00:02:32,530 --> 00:02:34,810 And again, I'll cancel the new download here. 47 00:02:35,410 --> 00:02:37,510 So let me make this full screen here. 48 00:02:38,650 --> 00:02:43,300 And as I mentioned before, if that setup wizard does not show up, you can start it here. 49 00:02:43,630 --> 00:02:45,160 Run the setup wizard. 50 00:02:46,390 --> 00:02:52,990 Okay, so now what we want to do is we want to create a new workspace and once we create the new workspace, 51 00:02:52,990 --> 00:02:56,380 we'll run a couple of settings to do, and then once that's done, it'll be all set. 52 00:02:56,380 --> 00:02:58,300 So let's create a new workspace. 53 00:02:58,330 --> 00:03:03,430 A workspace is basically an area where you can have different C++ projects in. 54 00:03:03,430 --> 00:03:05,890 So the first thing we want to do is create a new workspace. 55 00:03:05,890 --> 00:03:06,820 I'll select that. 56 00:03:06,820 --> 00:03:12,160 You can also say file new workspace, so I'll do it right here. 57 00:03:12,430 --> 00:03:14,620 And it's going to ask me for the name of the workspace. 58 00:03:14,620 --> 00:03:18,040 So I'll just say Keep workspace. 59 00:03:19,030 --> 00:03:20,650 You could do this whatever you like. 60 00:03:20,650 --> 00:03:26,950 If you want to have a workspace for all the section one exercises, section two, section three, or 61 00:03:26,950 --> 00:03:32,230 whatever you like, whatever it makes sense for you, I'm going to put it in my documents folder and 62 00:03:32,230 --> 00:03:37,270 I want to create the workspace under a separate directory that just helps me organize my files. 63 00:03:37,300 --> 00:03:37,870 I'll select. 64 00:03:37,870 --> 00:03:40,330 Okay, good. 65 00:03:40,330 --> 00:03:44,650 Now you can see here on the left pane of my workspace view, I've got a workspace now. 66 00:03:44,650 --> 00:03:47,200 The workspace in and of itself isn't real useful. 67 00:03:47,200 --> 00:03:54,310 I need to create a project within the workspace so I can right click on workspace and say new project. 68 00:03:54,880 --> 00:03:57,040 So I'll do that and I'll select new project. 69 00:03:57,820 --> 00:03:59,950 At this point, we've got some options. 70 00:04:01,060 --> 00:04:07,120 We're going to select the console option and then simple executable, G Plus Plus. 71 00:04:07,510 --> 00:04:10,750 That's basically the C++ compiler. 72 00:04:10,750 --> 00:04:13,210 It's called G Plus Plus because it's from Janu. 73 00:04:13,720 --> 00:04:18,070 So I'll select that next and then you give your project a name. 74 00:04:18,070 --> 00:04:19,959 This could be again any name you like. 75 00:04:19,990 --> 00:04:23,290 Avoid spaces just to be safe, just simple name. 76 00:04:23,290 --> 00:04:26,470 So I'll say test one, let's say. 77 00:04:27,370 --> 00:04:30,790 And again I want to create a project under in a separate directory. 78 00:04:31,330 --> 00:04:32,470 I'll press next. 79 00:04:33,520 --> 00:04:35,140 Here you can choose the compiler. 80 00:04:35,140 --> 00:04:37,300 It's probably already chosen it for you. 81 00:04:37,300 --> 00:04:43,090 If you've got multiple compilers, you can set individual compilers on a per project level, but we're 82 00:04:43,090 --> 00:04:46,900 using the GW compiler and we're using the new debugger. 83 00:04:47,500 --> 00:04:51,040 The build system will be default and select finish. 84 00:04:51,520 --> 00:04:53,860 So it's gone off and created a new project. 85 00:04:53,860 --> 00:04:55,330 You can see it here on the left side. 86 00:04:55,330 --> 00:04:56,380 It's called Test one. 87 00:04:56,380 --> 00:05:01,390 And as I explode these, you can see that there's my main CPP file. 88 00:05:01,480 --> 00:05:03,610 That's the program that it's created for me. 89 00:05:03,720 --> 00:05:04,560 By default. 90 00:05:04,650 --> 00:05:08,640 The DOT CPP extension means that it's a C++ file. 91 00:05:08,670 --> 00:05:14,460 I'm going to double click on that and you can see my font is pretty small here because I just installed 92 00:05:14,460 --> 00:05:14,670 this. 93 00:05:14,670 --> 00:05:16,170 Let me increase my font. 94 00:05:16,200 --> 00:05:20,040 You may not have to do this on your end, but it's going to show up better on video if I do it. 95 00:05:20,040 --> 00:05:26,010 So I'm going to go to settings, colors and fonts and I'll just set it to 16 I think should be nice. 96 00:05:27,840 --> 00:05:28,230 Okay. 97 00:05:28,260 --> 00:05:28,740 There we go. 98 00:05:28,740 --> 00:05:30,390 That way it's much easier for you to see. 99 00:05:30,420 --> 00:05:33,600 Now, what we want to do is we want to delete all this. 100 00:05:33,600 --> 00:05:36,300 This is actually C code, not C++ code. 101 00:05:36,300 --> 00:05:40,320 So let's delete all that and let's write a real simple test from scratch. 102 00:05:40,710 --> 00:05:46,140 So the first thing we'll do is we'll include IO Stream. 103 00:05:47,370 --> 00:05:52,830 This allows us to do input and output and we'll talk much more about what these include directives mean 104 00:05:52,830 --> 00:05:53,910 in a future video. 105 00:05:53,910 --> 00:05:58,020 In this example, just type along and make sure that the environment is working. 106 00:05:58,020 --> 00:06:02,640 So you want to say pound, include and IO stream and angle brackets. 107 00:06:03,090 --> 00:06:05,550 Then we want to say int space main. 108 00:06:05,550 --> 00:06:13,950 This is our main function to parens and we'll create a couple of curlies, curly braces. 109 00:06:14,660 --> 00:06:18,570 Then in here, all we're going to say is STD, colon, colon. 110 00:06:18,600 --> 00:06:27,270 See out the insertion operator, which is two less than sines followed by hello testing or anything 111 00:06:27,270 --> 00:06:31,620 you like and then a semicolon at the end and then finally return zero. 112 00:06:31,740 --> 00:06:32,340 That's it. 113 00:06:32,340 --> 00:06:33,660 That's a simple test. 114 00:06:34,200 --> 00:06:39,270 Again, there'll be a separate video where I go over the anatomy of a C++ program and we'll go over 115 00:06:39,270 --> 00:06:40,410 all this in detail. 116 00:06:40,410 --> 00:06:43,080 So in this case, again, we're including IO stream. 117 00:06:43,080 --> 00:06:47,580 We've got our main function and we're printing hello testing to the screen. 118 00:06:48,240 --> 00:06:50,820 We're returning zero, which means program successful. 119 00:06:51,810 --> 00:06:57,300 I'm going to save this and I'm not going to do this on the videos, but you can certainly do this at 120 00:06:57,300 --> 00:07:01,890 home if you come up to view and you can toggle the minimal view. 121 00:07:02,640 --> 00:07:08,100 When you do that, you'll get some icons up here and you can use these icons to build and say, for 122 00:07:08,100 --> 00:07:09,840 example, that's the save right there. 123 00:07:09,930 --> 00:07:14,010 I'm not going to do that because I want as much screen real estate as possible on the videos. 124 00:07:14,010 --> 00:07:17,040 So I'll just toggle that off. 125 00:07:18,390 --> 00:07:26,400 So I'm going to file save and at this point we're ready to run the program, but we need to make a couple 126 00:07:26,400 --> 00:07:30,120 of changes just because we want to use modern C++. 127 00:07:30,120 --> 00:07:36,630 So what we can do is we can click on the project test one in this example and I'll right click and down 128 00:07:36,630 --> 00:07:38,370 at the bottom you'll see settings. 129 00:07:38,550 --> 00:07:44,700 So we'll select settings and you can see right down here at the bottom where it says Global Settings, 130 00:07:44,700 --> 00:07:51,300 I want to select that and where it says C++ compiler options. 131 00:07:51,420 --> 00:07:55,590 You can click right in there and then you'll see these three little dots here on the button. 132 00:07:55,590 --> 00:07:57,930 So it gives us another menu so you can select that. 133 00:07:58,710 --> 00:08:00,840 And we want to make sure that a couple of things are set. 134 00:08:00,840 --> 00:08:05,040 We want to be sure that C++ 14 is checked. 135 00:08:05,490 --> 00:08:10,560 That means we're using the latest version of the standard, which is modern C++. 136 00:08:11,040 --> 00:08:16,020 We also want to be sure that the W lx all warnings is checked. 137 00:08:18,180 --> 00:08:19,260 So that's it for now. 138 00:08:19,260 --> 00:08:19,980 That'll be fine. 139 00:08:19,980 --> 00:08:21,120 We'll select OC 140 00:08:24,000 --> 00:08:28,060 and will apply and OC. 141 00:08:28,110 --> 00:08:28,770 Perfect. 142 00:08:29,730 --> 00:08:35,970 Now I also want to click on the workspace itself and right click on that and come down to workspace 143 00:08:35,970 --> 00:08:38,280 settings and select that. 144 00:08:38,280 --> 00:08:44,340 And when you come to code completion, you want to be sure that C++ 14 standard is enabled. 145 00:08:45,330 --> 00:08:48,960 Code completion is something that the IDE does as you type. 146 00:08:48,960 --> 00:08:52,740 It's trying to figure out what you want to do and help you out so you don't have to do a lot of typing. 147 00:08:52,890 --> 00:08:57,420 And in this case we want to tell it to use the for the C++ 14 standard. 148 00:08:57,420 --> 00:09:00,000 So when it's trying to figure things out, so I'll select. 149 00:09:00,000 --> 00:09:00,610 Okay. 150 00:09:01,260 --> 00:09:04,290 Now at this point, we should be ready to try this out. 151 00:09:04,290 --> 00:09:08,340 So I'm going to expand this little window down here at the bottom and I'm going to come up to where 152 00:09:08,340 --> 00:09:12,270 it says Build and then we'll select Clean Project. 153 00:09:14,090 --> 00:09:16,920 Then we'll go back to build and just say Run. 154 00:09:17,520 --> 00:09:19,400 At this point it's going to say, What do you want to do? 155 00:09:19,430 --> 00:09:20,280 Do you just want to run it? 156 00:09:20,280 --> 00:09:21,720 Or You want to build it and run it? 157 00:09:21,990 --> 00:09:23,670 In this case, I want to build it and run it. 158 00:09:23,670 --> 00:09:28,680 And I'll talk more about the workflow that's used for cleaning and compiling and so forth a little bit 159 00:09:28,680 --> 00:09:29,910 later on in the course. 160 00:09:30,750 --> 00:09:35,520 So in this case, I want to say build and execute and it will compile and run the program. 161 00:09:35,520 --> 00:09:39,690 If there are no errors, it'll run and you'll get a window pop up with the output. 162 00:09:39,690 --> 00:09:40,020 Hello? 163 00:09:40,020 --> 00:09:40,950 Testing in there. 164 00:09:40,950 --> 00:09:44,880 If there are errors, let me show you what they might look like, just in case you do see them. 165 00:09:45,810 --> 00:09:53,250 Suppose I forget that semicolon at the end there and I'm going to say build, run, build and execute. 166 00:09:53,520 --> 00:09:59,970 And you can see this red down here that says error expected a semicolon before the return. 167 00:09:59,970 --> 00:10:03,540 You also get a red error here and it says. 168 00:10:03,650 --> 00:10:05,110 Again, semicolon expected. 169 00:10:05,120 --> 00:10:12,800 So basically you just put the semicolon in there, save it and then go back up to build and run, build 170 00:10:12,800 --> 00:10:13,420 an execute. 171 00:10:13,430 --> 00:10:18,080 You can click on here for it to remember, to always build an execute or just execute again. 172 00:10:18,080 --> 00:10:18,890 Don't do that yet. 173 00:10:18,890 --> 00:10:22,700 We'll do that as the course progresses and I'll show you the different workflows we can use. 174 00:10:22,700 --> 00:10:23,960 So build and execute. 175 00:10:24,830 --> 00:10:25,670 There we go. 176 00:10:25,670 --> 00:10:33,020 Now, if at this point you get an error that says that some DLL can't be found, then what you want 177 00:10:33,020 --> 00:10:40,550 to do is you want to go back to the project, right click and go down to settings and remember you only 178 00:10:40,550 --> 00:10:47,390 have to do this if you get some kind of runtime error that says some CP DLL file is not found and go 179 00:10:47,390 --> 00:10:48,590 to global settings. 180 00:10:48,920 --> 00:10:54,410 And then what you want to do is you want to go to the linker options and just select right on there 181 00:10:54,410 --> 00:10:55,730 and click that little button. 182 00:10:56,480 --> 00:11:00,410 And down here at the bottom, what you want to do is you just want to add a couple of lines. 183 00:11:00,410 --> 00:11:14,220 You could say dash static, dash lib GCSE and then press enter and then dash static dash lib std c plus 184 00:11:14,300 --> 00:11:14,990 plus. 185 00:11:16,610 --> 00:11:21,530 So what will happen here is now the linker is going to statically link the files and not have to use 186 00:11:21,530 --> 00:11:23,870 dynamically linked libraries or DLLs. 187 00:11:24,530 --> 00:11:28,220 Again, you only have to do this if you if you get that error, if you don't get the error, you can 188 00:11:28,220 --> 00:11:29,570 do it also and it's not going to hurt. 189 00:11:29,570 --> 00:11:38,180 But I'll select OC apply and let's do a build, rebuild, let's do a clean first. 190 00:11:38,180 --> 00:11:42,380 Whenever you change any kind of settings, you want to clean the project, which really just cleans 191 00:11:42,380 --> 00:11:44,300 everything up and gives you a starting place. 192 00:11:44,300 --> 00:11:48,770 So we'll clean the project and then we'll just say, run, build and execute. 193 00:11:48,770 --> 00:11:52,010 In this case, it's going to statically link it, which is just as good. 194 00:11:52,340 --> 00:11:53,930 And hello, testing. 195 00:11:53,930 --> 00:11:55,670 We're all set at this point. 196 00:11:55,670 --> 00:11:57,200 We've got a good install. 197 00:11:57,200 --> 00:11:59,630 It's configured and we're ready to use code. 198 00:11:59,630 --> 00:12:01,670 Like to start learning C++.