Bring your C++ code to Visual Studio

C++ has been around for a long time and throughout its history many tools have been built to make life easier for C++ developers. This has led to a diverse C++ ecosystem in terms of the editing tools, build systems, coding conventions, and C++ libraries that we use in our day-to-day work. As a C++ developer, you are probably accustomed to using a variety of tools from different vendors for different purposes. Rest assured that you will not trade-in your flexibility in how you develop your C++ projects once you start using Visual Studio. Visual Studio provides industry-leading development tools for C++ for any platform you’re targeting.

Depending on a few characteristics of your C++ project, this document will guide you through the recommended steps to get started with Visual Studio. Read on each chapter to see if it fits the description of your project. This post is part of a Getting Started series aimed at C++ users that are new to Visual Studio.

Cross-platform C++ applications and libraries

Building with CMake

If your project targets multiple platforms, you are likely to use CMake to specify your build. The steps needed to move to Visual Studio are very simple in this case – just open the folder containing your CMakeLists.txt files and let Visual Studio do the rest. To learn more about using CMake in Visual Studio, read the CMake support in Visual Studio page.

Targeting Qt Framework or building with QMake

Qt framework is a cross-platform C++ framework; it is ideal for building desktop, mobile and even embedded solutions. While you can use CMake to target Qt (in which case you should review the above topic), Qt also offers its own Qt-optimized build system called qmake that supports non-Qt C++ projects as well. If you are using qmake, learn how to import your .pro projects into Visual Studio.

Building with a cross-platform C++ build system (make, ninja, gyp, scons, gradle, etc.)

There are many build systems that support C++ today for cross-platform scenarios. It is outside the scope of this document to recommend one over another. But regardless of which build system your project uses today, you can open it inside Visual Studio and with minimal configuration you can become productive. With any of these build systems, you can enable all or any of the following Visual Studio capabilities:

  • C++ editing (e.g. IntelliSense, code navigation)
  • Building
  • C++ debugging (e.g. Windows process debugging, attaching, remote debug, etc.)

To learn how to move to Visual Studio, read more about Open Folder support in Visual Studio 2017.

Linux C++ applications (including targeting server, cloud, IoT)

Are you developing a server-side component or a containerized binary running on Linux or maybe a critical component for an IoT device? Visual Studio provides support for targeting Linux out-of-the-box. You can edit, build and debug your C++ projects either by using a remote Linux machine or using the built-in Windows 10 Linux subsystem support. For a step-by-step guide to porting your projects to Visual Studio read Bring your existing C++ Linux projects to Visual Studio.

Android C++/Java applications

Using Eclipse

You can use Visual Studio to develop both your C++-only projects as well as C++/Java JNI-based projects targeting Android. If you’re currently using Eclipse, you can move to Visual Studio via our Eclipse Android Project Import Wizard. Follow the link to learn more about migrating your Eclipse Android projects to Visual Studio.

Using Gradle

Whether you already have a gradle-based build for your Android project, or you are just getting started targeting Android, Visual C++ provides the support you need to build Gradle projects. Visual C++ also offers a great editing and debugging experience for both your C++ and Java source code. To learn more, read about building your Android applications in Visual Studio using Gradle.

iOS Objective-C/C++ applications

If you’re targeting iOS and writing a lot of C++ code, you should consider importing your XCode projects into Visual Studio. Visual Studio not only provides an easy way to import these projects, but also allows opening these projects back in XCode if you need to make non-C++ related edits (e.g. storyboarding, UI design). Follow this link to learn more about migrating your XCode iOS projects to Visual Studio.

Windows C++ application

If your project targets Windows, you should consider using MSBuild as your C++ build system. With MSBuild, you can target from a single codebase all the platforms that Visual Studio supports today. You also get access to the C++ Project System that provides file and project management functionality that makes it easy to manage your project as it grows. You can easily addi references between projects, configuring PCH file, and configur compiler and linker switches across multiple projects). Learn more about migrating your C++ project to MSBuild.

What’s next

If you’re new to Visual Studio, learn more by reading the Getting Started with Visual Studio for C and C++ Developers topic and the rest of the posts in this Getting Started series aimed at C++ users that are new to Visual Studio. Download Visual Studio 2017 today, try it out and share your feedback.

If your C++ development scenarios are not covered today by Visual Studio, don’t hesitate to reach out to us at visualcpp@microsoft.com. We would love to learn more about it