i am getting error stating launch program does not exist
i installed c compiler mingw that is required for windows still facing errors while compiling. how can i run c program? I have installed all extensions related to c, c extensions, in fact i too have installed code runner. Earlier it showed a run button at the top but now its not showing instead of it is showing config to add.
You don't need a code runner. You can configure VSCode to allow you to run the code and also debug it in a much better way.
Check for GCC
Go to the terminal and type
gcc --versioninto it.If you get something like this:
It means GCC is installed and should be found by VSCode.
tasks.json
You'd have to give the correct paths to tasks.json to perform the builds and runs. Here's an example
This assumes that the executable name you want is the same as your folder name. For example if the folder name is
my_c_projectthen the executable would becomemy_c_project.exe. You can of course give custom names by replacing${workspaceFolderBasename}.To run it or debug it, you'd need
GDB. To check for it, usegdb --versionin a terminal and it should give you this output.And also you'd have to configure the launch configuration.
launch.json
Here's an example
The first important bit in it is the
programparameter which should point to the program created after building. You can see that thebuild debugandbuild releasetasks both create the executable at the base folder, (the same place where your main.c is placed). And so theprogramproperty oflaunch.jsonis also pointing to the same executable.And the second important bit is the
preLaunchTaskparameter which tells the debugger to perform a task before it starts debugging. It's been set to thebuild debugtask, so every time you debug, it will rebuild to let you use the latest code.Once you've set these up, just go to the debug tab and click on the green debug symbol on the top right.
And it would start debugging. Viola!