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 C++ Project 配置C++Project
- Visual Studio中的C,C++,C#C++C#
- visual studio原生支援C++的含義C++
- Visual Studio C++ 安裝以及使用教程C++
- 在Visual Studio上用C++ 寫LinuxC++Linux
- Visual Studio推出改進的C/C++支援C++
- Visual Studio部署C++環境下OpenCV庫C++OpenCV
- 利用Visual Studio除錯WSL下的C++工程除錯C++
- 用Visual Studio將Objective-C編譯為C++Object編譯C++
- Visual Studio Code
- C++ any_of用法學習C++
- 循序漸進:將 eMbedded Visual C++ 應用程式遷移到 Visual Studio 2005C++
- 呼叫Visual Studio的cl.exe編譯C/C++程式編譯C++
- Microsoft Visual Studio CodeROS
- 安裝 Visual Studio
- Visual Studio Tips
- 【Visual Studio調教小記錄】C++指標靠前靠後??C++指標
- Pre-defined C/C++ Compiler MacrosC++CompileMacROS
- Visual Studio - Now with Go support,你會用 Visual Studio來寫go嗎?Go
- OpenCV(c++)-1 安裝和配置OpenCV4.4(Windows+visual studioOpenCVC++Windows
- Visual Studio Code 配置C、C++ 檔案debug除錯環境C++除錯
- 如何在Visual Studio和CodeBlocks中反編譯C++程式碼BloC編譯C++
- 使用Visual Studio分析dump
- 【Python】—{Visual Studio Code}Python
- Visual Studio for Mac 簡介Mac
- C語言(Visual Studio)C語言
- Visual Studio 常用快捷鍵
- use azure data studio to create external table for oracleOracle
- 在Visual Studio 中使用git——給Visual Studio安裝 git外掛(二)Git
- Visual Studio 2005:在組織內部採用 Visual Studio ExpressExpress
- Huffman Tree (use priority queue) in C++C++
- FFmpeg開發筆記(三十九)給Visual Studio的C++工程整合FFmpeg筆記C++
- Visual Studio Code 使用筆記筆記
- Visual Studio Code 使用指南
- Visual Studio Code 1.78 釋出!
- Java on Visual Studio Code的更新Java
- visual studio golang環境配置Golang
- Visual Studio Code 使用心得