Hello and welcome.
In this video, I'm going to walk you through setting up the debugger in code lite for Windows.
Setting up the configuration.
Now, it's pretty straightforward as far as the settings go, but the issue is that code lite is definitely
somewhat buggy when it comes to the cygwin GDB debugger.
We're going to try a couple things.
First, we're going to try to use a particular version of GDB through Cygwin.
Sometimes that has worked for some students and other times it hasn't.
You can also try using the latest version of the cygwin GDB debugger and sometimes that will work.
But if all else fails we're going to have to revert and use the MinGW debugger for code lite and that's
perfectly fine.
We just have to make sure we use the compiler, the Cygwin compiler for code lite because we're using
advanced features of C and the MinGW doesn't have those advanced features, but using the debugger for
MinGW is perfectly fine.
So the first thing you should do is you should go to your browser and you should go to cygwin.com.
Remember we installed Cygwin earlier in the course.
If you go to the home page, you'll want to go to install Cygwin.
This is just a setup file that allows you to update packages, change versions and all those things.
So if you download setup x86 64 for Windows, you can download that anywhere on your device.
I'm just going to download it to my desktop and when I download that to my desktop, it may take a couple
minutes, but it's basically just going to install the setup for Cygwin so that we can change the version
of our GDB to use a particular version.
So here it is on my desktop.
If you double click this and run it again, you can actually pick what version of GDB to install.
So this is the first thing we're going to try.
We're going to try reverting to an older version of GDB, particularly the 9.2 version.
And so you just want to make sure that you install where you've already installed Cygwin, so you just
want to pick that same directory hit next and keep going until you actually get up the setup screen.
So you can just select whatever mirrors and so forth.
Again, we've done this already, we just want to revert our GDB.
So once you see this screen you can actually go to the view and you can just say full and you can select,
you can search for GDB.
At this point you should see that you have gdb installed.
So I have gdb installed and I have the latest version, but the latest version isn't working with code
light.
I keep getting strange errors so there are some versions of code light that will work with 9.2.one.
So if you go down to the dropdown, you select 9-2-1 and you select next you'll see that it's going
to uninstall GDB the latest version and it's going to then go ahead and install 9.2.one so you can go
ahead and select next and install that and it may take a couple of minutes and you can go ahead and
click finish once it's done and then once that's complete, you want to bring up code light and you
want to try to set the debugger settings to use that particular version of GDB.
So I'm going to go ahead and create a new project, just say new project and we'll just call this project
debugger test and we're going to actually not use the template.
You can always add this to your template later, but we're just going to do a console app.
The type is going to be simple executable GCC and we're going to specify the debugger to be GDB debugger.
So I'm going to hit.
Okay.
And now there's a couple ways to set your debugger settings.
You can go up to settings and you go to GDB settings and for your debugger path under general, you
can point to the version of Cygwin that we just downloaded the GDB, but that's not always necessary.
You can.
These are supposed to be the global settings, but I don't think they necessarily get inherited for
every project.
So your best bet, best bet is to click on the project, go to settings and select the debugger on the
left hand side and says select the debugger path.
You want to point it to your cygwin bin folder.
So if you select the dot, dot, dot and you go to see Cygwin 64 wherever you downloaded it bin and
then GDB and so here we go to GDB and we select that.
And so you see that path there in there and you just say apply and you say, okay, now in our debugger
test, one way to test to see if the debugger is actually working, you can go to your main dot C file.
And on the margin where the line numbers are, you can just select inside of the main function.
Maybe on line five, you can select it and you'll see this red circle appear.
This is called the breakpoint.
We're going to talk about these in a lot more detail later.
But this will essentially stop the execution of your program at this line of code if you run the debugger.
And so to test to see if the debugger worked, we're going to go up to the debugger and we're going
to say start, continue debugger and we're going to say build and debug.
And at this point, you should try to run the debugger and you'll notice that nothing happened.
For me, it just came up and it closed and so it didn't catch that breakpoint.
So unfortunately 9.2.one is not working for me for the Cygwin debugger.
If this doesn't work for you, you could try installing the latest version of GDB just like I did a
minute ago where you bring up the cygwin setup and you select GDB and then you select the latest version
and then you could point to path to that.
That's another option.
But again, I haven't been able to get those to work.
It's been really confusing.
I've posted in the Code Lite forums, I've asked questions.
It seems like it's a common problem, a common bug.
So if all else fails, what I would suggest you do is install the MinGW debugger.
And so at this point, let's walk through that.
If you bring up your browser, so you want to navigate to basically the download page of wind libs.
So you want to go to wind libs right at the top here, wind libs.com/pound download release.
And once you select that you'll see that it says release versions and you'll want to select the one
for Windows.
I would suggest selecting it for Wind 64 and I usually select the zip archive that's GCC.
The current record time of this recording of this video, it's 12 .2.0, but you can just grab the latest
version.
So if you select zip archive, it's going to ask you to save that.
You can save it wherever you want.
It's going to be a zip file.
It will go ahead and download that and it's not too big, but it may take a little bit.
It's about 308MB.
Once that's downloaded, you will have to extract it somewhere.
I would suggest extracting it right where you extracted your cygwin folder.
Maybe in C, I actually extracted it to c min GW.
So once that's done you'll see that it's downloaded.
I download it to my desktop, you can right click on it.
You'll need a WinZip application or winrar to extract it, but you can right click on it and say extract
and then extract it wherever you want.
Again, I've already downloaded and extracted it.
I've downloaded it to my C drive.
So if.
I go to my C drive.
You'll see that I have min GW 64.
That's where I extract it.
And inside there there is a bin folder with your GDB executable and that's the one we want to point
to in code light.
So now that I've downloaded and I've extracted it, I'm going to go back to code light.
I'm going to have my example project here and in my project settings I can select my project right click
and I can say settings.
And now, instead of pointing the path to Cygwin, I'm going to point the path to my min GW bin folder.
So if I hit the dot dot dot, I can go to see min GW 64.
The one you just downloaded remember bin and then gdb gdb dot exe and I can go ahead and select that
and you'll see that path placed inside there so that I can hit apply and I can hit.
Okay.
Now again, to test this, you'll want to set a breakpoint and run the debugger to see if it actually
hits that breakpoint.
So you can go up to like line five, make sure you have the right file selected for the right project.
You can select line five.
Add that circle for that breakpoint.
Go up to your debugger.
You can say start, continue debugger, build and debug and then it should hit that breakpoint.
And that's what happens, right?
You see the program stop execution.
There's a little green arrow next to the five and then the debugger window comes up.
Right?
And that means that the debugger is working.
And so you were able to successfully install and configure the debugger, the MinGW debugger for code
light.
Now we're going to talk about how you can run through the debugger and do all the options and how it's
useful for finding errors in your code.
But right now we just want to make sure that we were able to successfully configure and install the
debugger to stop the debugger.
You can just hit the stop the red rectangle right there.
Now there are also settings right at the top GDB settings.
I've noticed that this doesn't need to be set if it's set in the project.
I've also noticed that when I do set it, so if I go ahead and I set this to gdb that it doesn't necessarily
apply to every single project.
So if I set the c GW 64 bin, it doesn't actually work when you create new projects, so you always
have to set it in the project settings.
I'm not sure why setting it here, setting it here should set it up for all projects and maybe it does
later.
But right now I'm just setting it in my project settings.
So if it's in your project settings and you might as well just keep it in here set anyways.
And you can see there's some other options.
Usually all the default options are perfectly fine.
Now since that's a project setting, you definitely may want to add it to a new template, create a
new template, and then make sure that you have all your settings correctly right?
So you can go to project settings.
And for debugging, you always want to make sure that the compiler is compiling for debugging and opting
for optimizations for debugging by default.
It already does that, but you should see for the C compiler g dwarf 2-O and so forth.
Those always have to be set.
And you also have to make sure that when you build, you build for a debug release.
So remember up here, we talked about this before debug and release.
If you're built for release, you're not going to have debugging information.
You won't be able to separate points.
So you always want to make sure that debug is selected and that's about it, right?
You can play around with other settings, but really all you need to do is set that path to the correct
GDB executable.
And because code light is somewhat buggy with the cygwin gdb and I don't know why.
Again you can try to use the latest version of cygwin gdb you can use an older version, maybe you'll
get it working, but if all else fails, just set the project settings to the MinGW w64 debugger and
you can use that while debugging on Windows in code light.
If you have any questions on the form, let me know.
Thank you.