Use any C++ Compiler with Visual Studio
Use any C++ Compiler with Visual Studio
Avatar
Will
March 7th, 2017
Microsoft Visual Studio 2017 supports several C++ compilers to suit a wide variety of codebases. In addition to the Microsoft Visual C++ compiler that many of you are likely familiar with, Visual Studio 2017 also supports Clang, GCC, and other compilers when targeting certain platforms.
This post is intended to familiarize you with the variety of C++ compilers that are compatible with the Visual Studio IDE, and to understand when they might be applicable to use with your projects. Some compilers may be better suited to your needs depending on your project or target. Alternatively, you may be interested in checking out new language features, such as C++ Concepts, that are not available across all compilers without needing to leave the IDE.
You can select the compiler and corresponding toolset that will be used to build a project with the “Platform Toolset” property under General Configuration Properties for C++ projects. Any installed compilers that are applicable to your project type will be listed in the “Platform Toolset” dropdown.
Microsoft C++ Compiler (MSVC)
If you are targeting Windows, the Microsoft C++ compiler (MSVC) may be the way to go. This is the default compiler for most Visual Studio C++ projects and is recommended if you are targeting Windows.
Compiler options for the Microsoft C++ compiler.
Compiler options for the Microsoft C++ compiler.
Clang
You can use the Clang compiler with Visual Studio to target Android, iOS, and Windows.
If you are targeting Android, you can use the Clang/LLVM compiler that ships with the Android NDK and toolchain to build your project. Likewise, Visual Studio can use Clang running on a Mac to build projects targeting iOS. Support for Android and iOS is included in the “Mobile Development with C++” workload. For more information about targeting Android or iOS check out our posts tagged with the keywords “Android” and “iOS”.
If you are targeting Windows, you have a few options:
Use Clang/LLVM; “Clang for Windows” includes instructions to install Clang/LLVM as a platform toolset in Visual Studio.
Use Clang to target Windows with Clang/C2 (Clang frontend with Microsoft Code Generation).
Compiler options for the Clang/C2 compiler.
Compiler options for the Clang/C2 compiler.
It might make sense to use Clang/C2 if you want to bring a codebase that takes advantage of Clang’s language features to the Windows platform. Since the code generation and optimization is handled by the MSVC backend, binaries produced by Clang/C2 are fully compatible with binaries produced by MSVC. You can learn more about Clang/C2 from Clang with Microsoft Codegen – or check out the latest updates in posts tagged with the keyword “clang”.
GCC
If your project targets Linux or Android, you can consider using GCC. Visual Studio’s C++ Android development natively supports building your projects with the GCC that ships with the Android NDK, just like it does for Clang. You can also target Linux – either remotely or locally with the Windows Subsystem for Linux – with GCC.
Compiler options for GCC.
Compiler options for GCC.
Check out our post on Visual C++ for Linux Development for much more info about how to use Visual Studio to target Linux with GCC. If you are specifically interested in targeting WSL locally, check out Targeting WSL from Visual Studio.
Closing
Visual Studio also makes use of the Edison Design Group (EDG) frontend to provide flexible IntelliSense regardless of whether you use MSVC, Clang, or GCC to build your code. Visual Studio gives you access to a wide range of choices when it comes to C++ compilers. This way you can make sure that as you develop your code, it continues to compile against all major compilers.
Install Visual Studio today and give it a try. Please let us know if we have missed any compilers you use, and share your feedback as we look forward to improving your C++ development experience.
相關文章
- VISUAL-STUDIO(2022)-透過Visual Studio Installer新增C++工作負載C++負載
- visual studio原生支援C++的含義C++
- Visual Studio C++ 安裝以及使用教程C++
- Visual Studio部署C++環境下OpenCV庫C++OpenCV
- 利用Visual Studio除錯WSL下的C++工程除錯C++
- Visual Studio Code
- Visual Studio Tips
- 呼叫Visual Studio的cl.exe編譯C/C++程式編譯C++
- 【Python】—{Visual Studio Code}Python
- Microsoft Visual Studio CodeROS
- 安裝 Visual Studio
- Visual Studio 快捷鍵
- Visual Studio Code 配置C、C++ 檔案debug除錯環境C++除錯
- 【Visual Studio調教小記錄】C++指標靠前靠後??C++指標
- Visual Studio 常用快捷鍵
- 【譯】Database Profiling with Visual StudioDatabase
- 使用Visual Studio分析dump
- 在Visual Studio 中使用git——給Visual Studio安裝 git外掛(二)Git
- OpenCV(c++)-1 安裝和配置OpenCV4.4(Windows+visual studioOpenCVC++Windows
- C++ any_of用法學習C++
- Visual Studio Code 使用指南
- Visual Studio 2017 常用快捷鍵
- Visual Studio 2017 15.8概覽
- visual studio 2015快捷鍵整理
- Visual Studio Code 1.78 釋出!
- Visual Studio Code 和 GitHub CopilotGithub
- Visual Studio Code 1.77 釋出!
- Visual Studio 2019更新到16.2.3
- Visual Studio 2019更新到16.2.1
- Visual Studio 2019更新到16.2.2
- Visual Studio Code 使用筆記筆記
- Visual Studio 2019更新到16.1.6
- Visual Studio 2019更新到16.1.4
- Visual Studio 使用GIT詳解Git
- 使用Visual Studio分析.NET Dump
- visual studio golang環境配置Golang
- Java on Visual Studio Code的更新Java
- Visual Studio 2015 新新增巨集