Cant run a program in VScode

Every time I run a code from the run without debugging option, it shows up a launch.json window and when I type cl (file name), it says incorrect command.

@DanM

Please use the Ask sub forum for asking questions/issues in the future.

Using run without debugging would require writing a launch.json so that’s expected.

As for cl, did you open VS Code through the developer command prompt?

Yes, I opened it from the prompt command
but the cl command wont work.

Could you show the output of “cl” in the developer command prompt (not in VS Code).

Sure!

That looks fine. So using this to open VS Code (by typing “code”), the integrated terminal in VS Code doesn’t work with “cl”? What if you close that integrated terminal and open a new one?

How can I open a new terminal?
Every time I open a new terminal the integrated terminal pops up

That’s what I was suggesting. Could you show a screenshot of what you’re getting?

sure!

I’m not seeing anything wrong with that. Could you show the error you’re getting?

yeah!

i am not gettin hello world in the output

  1. You’re not compiling the file. You didn’t add the file extension so the compiler is assuming you meant
    cl xxx.obj game.obj
    
    You need to add the .cpp file extension. As your file also has spaces in it you will need quotes so it sees it as one file and not two.
     cl "xxx game.cpp"
    
  2. Compiling isn’t supposed to output hello world. It creates the program and by default will name it after the same name as the file i.e. in your case “xxx game.exe”. Type that to run it.

Got it! Thank you so much!
I understood how it works now.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms