Personally I prefer Xcode when coding on a Mac. It's not hard to learn, but because it is fairly new there aren't many useful videos or articles on how to navigate Visual Studio Code. If you are familiar with Visual Studio IDE for Microsoft Windows, Visual Studio Code is a totally different program. The moderator on the second link said specifically that the visual studio version for Mac does not support C, it only supports ' Mobile with.NET: Android, iOS, tvOS, watchOS Mac desktop apps.NET Core applications ASP.NET Core Web applications Cross-platform Unity games' I. Microsoft visual studio 2014 free download - Visual Studio Code, Real Studio, Visual SEO Studio, and many more programs. To install Visual Studio 2015, go to Download older versions of Visual Studio. Run the setup program and choose Custom installation and then choose the C component. To add C and C support to an existing Visual Studio 2015 installation, click on the Windows Start button and type Add Remove Programs.
Introduction
Microsoft’s Visual Studio product ever since the ’90s (was Visual C++ back then) has been my primary C++ IDE and I still love using it for the majority of my coding needs. Unfortunately it hasn’t been as convenient to use since after I switched to Macbook. I’m not a fan of boot camp, so I have been using virtualization software to run Visual Studio and the load on the system has depricated the experience.
A while ago Microsoft’s cross platform editor Visual Studio Code caught my eye so I gave it a go. Judging by my experience so far, VS Code will probably change my habit, at least for solo non-critical projects. It supports a variety of scripting languages out of the box, but how was the experience for native C++ development with Boost ? Try for yourselves.
Steps
Unlike Visual Studio, Visual Studio Code doesn’t support C++ language out of the box. Luckily, it has a great built-in marketplace. I will be using CMake as the building environment. This way, your code should compile and run on every platform without any need of modification whatosever. CMake is beautiful.
There is an official guide for C++ here which is not CMake oriented. I also had several problems in successfully running the code as described here.
Prerequisites
Download and install Visual Studio Code from official download site
Download and install CMake from official download site
You also need standard C++ libraries. Installing XCode on Mac or Visual Studio on Windows should take care of that. Otherwise you need to install them manually and define include directories in c_cpp_properties.json
C++ Extensions
- Install C/C++ extension. This is an official Microsoft extension.
- Install CMake extension.
- Install CMake Tools extension. This enables usage of a set of CMake commands from inside VS Code.
- I also installed Native Debugger.
Here is the official guide on extensions.
Creating Project
Visual Studio Code works with folders. Create a folder at your projects directory. Let’s say “HelloBoost”. Open the folder from VS Code’s File menu.
- Create new file (
⌘N
on Mac) and name it main.cpp.
- Create another file and name it “CMakeLists.txt”
Json Files
Visual Studio Code configurations work with JSon files inside ./vscode
subfolder of the project. In the end, we are going to have three JSon files in there.
- First one is
cmaketools.json
Not going into details of CMake itself, but this is how it works on Visual Studio Code.
Open Command Palette, ⇧⌘P
on Mac, or from View menu. Run >CMake: Build
command. Select Debug
.
This should create the following structure:
- Second is
c_cpp_properties.json
, which determines the include directories. To create this file open Command Palette and run>C/Cpp: Edit Configurations
. You may then edit this file to change include directories for each configuration for various operating systems. On Mac, we are assuming XCode is installed. This file looks like this;
launch.json
is the final one which tells the debugger what to do. Open Command Pallete and run>Debug: Open launch.json
. The dropdown will ask you to select environment. SelectC++ (GDB/LLDB)
. This should create launch.json file which should look something like below;
All you need to do is change 'program'
line to
'program': '${workspaceRoot}/build/HelloBoost',
I also change externalConsole
to false
since I prefer using VS Code’s built-in debugger console.
This is the final look on files.
C++ Debugging
Now everything you need to debug C++ code is set-up. From the Command Palette run >CMake: Build
again. Once it is built, put a breakpoint (if you like) into your main function and hit F5
. Debugger should hit your breakpoint, and you can move onto next line with F10
as you normally would on Visual Studio. VS Code’s built-in Debug Console should display “Hello World”.
Installing Boost
Download the appropriate Boost library from here.
You can use the prebuilt windows binaries or build it yourself for Mac. Here is how to do it on mac;
Download the .tar.gz, extract it, open a terminal (or use VS Code’s built-in terminal) and build it using Clang.
On terminal;
CMake with Boost
Edit CMakeLists.txt file and change it to;
Normally find_package should be able to find boost, but I included BOOST_ROOT directory in case it fails for you. Also set options to use static-multithread-release libraries. Most of the boost libraries are header only, but I added several non-header boost libraries just to show how it is done.You may also want to edit c_cpp_properties.json
file and add boost include path ('/usr/local/boost-1.65.1/include',
for me).
To make sure boost libraries are ready, change main.cpp
file to;
Finally from the command palette, run >CMake: Clean
, >CMake:Build
and hit F5
to debug.
The End
Download Visual Studio Mac
If all is well and running, you can enjoy using Visual Studio Code as a decent IDE for some high performance development action with C++ & Boost. So far, I’m having a decent experience under Visual Studio Code and hope you feel the same.
Adios,
Ayhan
Microsoft today announced that Visual Studio 2019 for Windows and Mac has hit general availability — you can download it now from visualstudio.microsoft.com/downloads. Visual Studio 2019 includes AI-assisted code completion with Visual Studio IntelliCode. Separately, real-time collaboration tool Visual Studio Live Share has also hit general availability, and is now included with Visual Studio 2019.
Microsoft launched Visual Studio 2017 in March 2017 and Visual Studio 2017 for Mac in May 2017, which turned out to be the “most popular Visual Studio release ever.” The company announced Visual Studio 2019 for Windows and Mac in June, and started releasing Visual Studio 2019 previews in December.
Visual Studio 2019 improves on Visual Studio 2017 across the board. It includes a new start window experience to get developers into their code faster (making it simpler to clone a Git repo or to open an existing project or folder), improved template selection screen, increased coding space, a new search experience, more refactoring capabilities, a document health indicator, and smarter debugging. Plus, all of the above works with both your existing project and new projects — from cross-platform C++ applications, to .NET mobile apps for Android and iOS written using Xamarin, to cloud-native applications using Azure services.
New features
The new start window on launch is designed to work better with today’s Git repositories, including local repos, Git repos on GitHub, and Azure Repos. Git aside, you can still open a project or a solution or create a new one of either.
Visual Studio’s UI and UX have also received subtle changes, such as a new product icon, a cleaner blue theme, and a more compact title and menu bar. There’s also a new search experience that replaces the Quick Launch box. It lets you find settings and commands and install options, and it even supports fuzzy string searching.
Visual Studio 2019 improves the code maintainability and consistency experiences with new refactoring capabilities — such as changing for-loops to LINQ queries and converting tuples to named-structs. There’s also a new document health indicator and code clean-up functionality.
As for debugging, stepping performance is improved and search capabilities have been added to the Autos, Locals, and Watch windows. You can also expect improvements to the Snapshot Debugger to target Azure Kubernetes Service (AKS) and Virtual Machine Scale Sets (VMSS), and better performance when debugging large C++ projects, thanks to an out-of-process 64-bit debugger.
IntelliCode and Live Share
At its Build 2018 developers conference in May, Microsoft previewed IntelliCode and Live Share. The former uses AI to offer intelligent suggestions that improve code quality and productivity, and the latter lets developers collaborate in real time with team members who can edit and debug directly from Visual Studio and Visual Studio Code.
Visual Studio IntelliCode now has custom models and expanded language support. Custom models further improve the AI-enhanced IntelliSense, giving developers personalized recommendations based on the patterns and libraries used in their code, on top of the analysis made on thousands of open source repos. Visual Studio developers now get IntelliCode for XAML and C++ code, in addition to C#. Visual Studio Code developers can use IntelliCode when developing JavaScript, TypeScript, Python, and Java.
Visual Studio Live Share, which is now installed by default in Visual Studio 2019, helps developers collaborate in real time, including desktop app sharing, source control diffs, and code commenting. Being able to share, edit, and debug code is great, but being able to do so without needing to clone repos or set up environments is even better. Based on feedback, Microsoft also added features like read-only mode, support for additional languages like C++ and Python, and enabled guests to start debugging sessions. Live Share can be used in a variety of use cases, including pair programming, code reviews, giving lectures, presenting to students and colleagues, or even mob programming during hackathons.
Learning Visual Studio 2019
For a full run-down of all the additions and improvements, check out what’s new, the docs, and release notes (Windows, Mac). Furthermore, Pluralsight has a free Visual Studio 2019 course available until April 22, while LinkedIn Learning has a free course available until May 2.
Microsoft is also hosting a virtual Visual Studio 2019 Launch Event and over 70 local launch events around the world today where it will demo the new version and detail its features. The company has also planned over 200 more events between now and the end of June. If all else fails, there’s always the Visual Studio Developer Community.