Using Unity and Visual Studio for Mac, you can create awesome games that run on any platform. Use the powerful coding, refactoring, and debugging features in Visual Studio for Mac to enhance your productivity. @VladLazarenko, by 'Visual C++ program', I meant a program created using MS Visual C++. I didn't mean a program written in a programming language called Visual C++. I think this is fairly clear from my question, but I'm sorry if it wasn't clear to you. Download Visual Studio Code for macOS. Double-click on the downloaded archive to expand the contents. Drag Visual Studio Code.app to the Applications folder, making it available in the Launchpad.
Active1 month ago
Microsoft's Visual Studio Code editor is quite nice, but it has no default support for building C++ projects.
This session covers the nuts and bolts of several key innovative compiler and runtime technologies we will be delivering in Visual Studio 2015 and its updates.
How do I configure it to do this?
Peter Mortensen
14.4k1919 gold badges8888 silver badges117117 bronze badges
user3703887
12 Answers
There is a much easier way to compile and run C++ code, no configuration needed:
Moreover you could update the config in settings.json using different C++ compilers as you want, the default config for C++ is as below:
Jun HanJun Han
7,01166 gold badges2020 silver badges2525 bronze badges
The build tasks are project specific. To create a new project, open a directory in Visual Studio Code.
Following the instructions here, press Ctrl + Shift + P, type
Configure Tasks , select it and press Enter.
The tasks.json file will be opened. Paste the following build script into the file, and save it:
Now go to menu File → Preferences → Keyboard Shortcuts, and add the following key binding for the build task:
Now when you press F8 the Makefile will be executed, and errors will be underlined in the editor.
BeeOnRope
29.7k99 gold badges9898 silver badges203203 bronze badges
user3703887
A makefile task example for new 2.0.0 tasks.json version.
In the snippet below some comments I hope they will be useful.
attdonaattdona
5,34522 gold badges1919 silver badges2525 bronze badges
Out of frustration at the lack of clear documentation,I've created a Mac project on github that should just work (both building and debugging):
Note that it requires XCode and the VSCode Microsoft cpptools extension.
I plan to do the same for Windows and linux (unless Microsoft write decent documentation first..).
peegee123peegee123
Here is how I configured my VS for C++
Make sure to change appropriete paths to where your MinGW installed
launch.json
tasks.json
c_cpp_properties.json
Reference:
Li KuiLi Kui
If your project has a CMake configuration it's pretty straight forward to setup VSCode, e.g. setup
tasks.json like below:
This assumes that there is a folder
build in the root of the workspace with a CMake configuration.
There's also a CMake integration extension that adds a 'CMake build' command to VScode.
PS! The larsmoalarsmoa
problemMatcher is setup for clang -builds. To use GCC I believe you need to change fileLocation to relative , but I haven't tested this.
9,42144 gold badges5151 silver badges7575 bronze badges
Here is how I configured my VS for C++ using g++ compiler and it works great including debugging options:
tasks.json file
launch.json file
I also have 'C/C++ for Visual Studio Code' extension installed in VS Code
Vlad BezdenVlad Bezden
36k1515 gold badges156156 silver badges123123 bronze badges
With an updated VS Code you can do it in the following manner:
3,50199 gold badges3030 silver badges4040 bronze badges
PoornamithPoornamith
There's now a C/C++ language extension from Microsoft. You can install it by going to the 'quick open' thing (Ctrl+p) and typing:
You can read about it here:
It's very basic, as of May 2016.
Community♦
EliotEliot
1,17722 gold badges1414 silver badges3737 bronze badges
You can reference to this latest gist having a version
2.0.0 task for Visual Studio Code, https://gist.github.com/akanshgulati/56b4d469523ec0acd9f6f59918a9e454
You can easily compile and run each file without updating the task. It's generic and also opens the terminal for input entries.
Peter Mortensen
14.4k1919 gold badges8888 silver badges117117 bronze badges
Akansh GulatiAkansh Gulati
60233 gold badges77 silver badges2525 bronze badges
The basic problem here is that building and linking a C++ program depends heavily on the build system in use. You will need to support the following distinct tasks, using some combination of plugins and custom code:
..but note conflicts with:
WARNING: IN ALL OF THE ANSWERS BELOW, ANYTHING THAT BEGINS WITH A 'VERSION' TAG BELOW 2.0.0 IS OBSOLETE.
Here's the closest thing I've got at the moment. Note that I kick most of the heavy lifting off to scripts, this doesn't really give me any menu entries I can live with, and there isn't any good way to select between debug and release without just making another three explicit entries in here. With all that said, here is what I can tolerate as my .vscode/tasks.json file at the moment:
}
Note that, in theory, this file is supposed to work if you put it in the workspace root, so that you aren't stuck checking files in hidden directories (.vscode) into your revision control system. I have yet to see that actually work; test it, but if it fails, put it in .vscode. Either way, the IDE will bitch if it isn't there anyway. (Yes, at the moment, this means I have been forced to check .vscode into subversion, which I'm not happy about.) Note that my build scripts (not shown) simply create (or recreate) a DEBUG directory using, in my case, meson, and build inside it (using, in my case, ninja).
breakpointbreakpoint
To Build/run C++ projects in VS code , you manually need to configure tasks.json file which is in .vscode folder in workspace folder .To open tasks.json , press ctrl + shift + P , and type Configure tasks , and press enter, it will take you to tasks.json Invision studio for mac.
Here i am providing my tasks.json file with some comments to make the file more understandable , It can be used as a reference for configuring tasks.json , i hope it will be useful
tasks.json
Now , stating directly from the VS code tasks documentation
description of type property :
The behavior of the terminal can be controlled using thepresentation property in tasks.json . It offers the following properties:
joker007joker007
protected by Community♦May 22 '16 at 10:53
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS. The extension is still in preview and our focus is code editing, navigation, and debugging support for C and C++ code everywhere that VS Code runs. The extension also supports Remote Development in the Visual Studio Code Insiders build. Microsoft lifecam studio for windows 10.
If you just want a lightweight tool to edit your C++ files, Visual Studio Code is a great choice. But if you want the best possible experience for editing, testing and debugging your existing Visual C++ projects or debugging on Windows, we recommend Visual Studio. Visual Studio Community is a free edition. It includes:
If you run into any issues or have suggestions for the Microsoft C/C++ extension, please file issues and suggestions on GitHub. If you haven't already provided feedback, please take this quick survey to help shape this extension for your needs.
Getting StartedVisual Studio For Mac Tutorial
To install the Microsoft C/C++ extension:
C++ Visual Studio For Mac
Visual Studio For Mac Can I Program In C++ Debug
To install support for Remote Development:
Visual Studio Professional For Mac
Visual Studio Community For Mac
Note: The C/C++ extension does not include a C++ compiler or debugger. You will need to install these tools or use those already installed on your computer. Popular C++ compilers are GCC on Linux or in a Mingw-w64 environment on Windows, Clang for XCode on macOS, and the Microsoft C++ compiler on Windows. Make sure your compiler executable is in your platform path so the extension can find it. The extension also supports the Windows Subsystem for Linux.
For instructions on configuring VS Code for specific environments, see:
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |