1

I am making a c++ program in vscode.
And i want to compile the c++ program using a specific command (for example g++ file_name.cpp -o file_name.exe). But cant understand how to do it using tasks in vscode?
All i want is to be able to run the above compilation command on the powershell in vscode. How can i do it??

0

2 Answers 2

2

I recently found out how to do it.

  1. You can download the coderunner extension in vscode.
  2. Then go to the settings of this extension.
  3. Then go to the executor_map.json folder.
  4. In this folder you will see json pairs like key value pairs.
  5. The 'key' is the language name and 'value' is the string which is directly pasted in the powershell of vscode.
  6. So now you can easily modify the string to build your projects the way you want.
  7. For Example in the case of C++ , I can give a g++ command with a lot of different flags like -Wall -Wshadow etc.
  8. Code runner also auto detects the language you are working in. All you need to do is just press run, and your project will be build using your custom command.
  9. If there is some other easier way you can share that too.
Sign up to request clarification or add additional context in comments.

Comments

2

Just click "Terminal" then "New Terminal" in the toolbar above, you'll get a powershell terminal by default. enter image description here

1 Comment

Yes thats a simple way to open powershell. But i was talking about the how to have your own build commands for any language

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.