C++ Set up in VS Code

This is a very elementary step before proceeding with a project and I have been following the instructions in the link below. I’ve tired to create the executable C++ file to test my VS Code set up with no luck.

[C++ programming with Visual Studio Code]


What operation system do you use and what error do you get?

Also, please, provide your code, which you try to compile.

1 Like

Thank you for your reply.
I am using macOS Monterey 12.0.01

The code below was copied and pasted into VS Code from this codecademy course link:

#include <iostream>

int main()
    std::cout << "Hello World" << std::endl;

This code is intended to test to see if I have a compiler in place.
It intends to create an executable file. But, it does not.

I clicked the Run Build Task from the menu bar and got four choices that drop down.
The insx show to use this option:

But, it is not available as such exactly. So, I chose the option that is the closest which is g++ without the “.exe”
So I am not getting an executable file in the file explorer as the insx expect.

I hope this makes sense? Thanks for any assistance.

Do you have a link to the original instructions (on the codecademy side)? You’d have an easier time if you found a set that weren’t for Windows like these seem to be.

If you’re on OSX clang or g++ are probably better but it sounds like that’s what you’ve used (a screenshot of your own options might be useful). If you ignore VSCode for the moment can you compile from the terminal, e.g. navigate to the same folder location and use g++ file.cpp, do you wind up with a.out or can g++ not be found.

If that’s more confusing than helpful then there is a set of instructions from VSCode on making use of the clang compiler: Configure VS Code for Clang/LLVM on macOS

That might be easier to follow and you can always change to use a different compiler once you’re more comfortable with the set-up (if you really wanted to).

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