在 Visual Studio 中安裝 C++ 支援Install C++ support in Visual Studio

如果您還沒有下載並安裝 Visual Studio 和視覺效果C++工具,這裡的 如何開始使用。If you haven't downloaded and installed Visual Studio and the Visual C++ tools yet, here's how to get started.

Visual Studio 2019 安裝Visual Studio 2019 Installation

歡迎使用 Visual Studio 2019!Welcome to Visual Studio 2019! 在此版本中,您可以輕鬆選擇並安裝需要的功能。In this version, it's easy to choose and install just the features you need. 因為降低了磁碟使用量下限,所以安裝快速,且對系統影響更小。And because of its reduced minimum footprint, it installs quickly and with less system impact.

注意

本主題適用於在 Windows 上的 Visual Studio 的安裝。This topic applies to installation of Visual Studio on Windows. Visual Studio Code是一種輕量型、 跨平台的開發環境,在 Windows、 Mac 和 Linux 系統上執行。Visual Studio Code is a lightweight, cross-platform development environment that runs on Windows, Mac, and Linux systems. Microsoft C /C++適用於 Visual Studio Code延伸模組支援 IntelliSense、 偵錯程式碼格式設定,自動完成。The Microsoft C/C++ for Visual Studio Code extension supports IntelliSense, debugging, code formatting, auto-completion. Visual Studio for Mac 不支援 Microsoft C++,但可支援.NET 語言和跨平台開發。Visual Studio for Mac doesn't support Microsoft C++, but does support .NET languages and cross-platform development. 如需安裝指示,請參閱安裝 Visual Studio for MacFor installation instructions, see Install Visual Studio for Mac.

是否想要深入了解此版本的其他新功能?Want to know more about what else is new in this version? 請參閱 Visual Studio版本資訊See the Visual Studio release notes.

準備要安裝了嗎?Ready to install? 我們將逐步引導完成安裝。We'll walk you through it, step-by-step.

步驟 1:請確定您的電腦已準備好安裝 Visual StudioStep 1 - Make sure your computer is ready for Visual Studio

在您開始安裝 Visual Studio 之前:Before you begin installing Visual Studio:

  1. 檢查系統需求Check the system requirements. 這些需求可以幫助您了解電腦是否支援 Visual Studio 2019。These requirements help you know whether your computer supports Visual Studio 2019.

  2. 套用最新的 Windows 更新。Apply the latest Windows updates. 這些更新可以確保您的電腦已具備最新的安全性更新,以及 Visual Studio 所需的系統元件。These updates ensure that your computer has both the latest security updates and the required system components for Visual Studio.

  3. 重新開機。Reboot. 重新開機可以確保不會有任何擱置的安裝或更新會阻礙 Visual Studio 安裝。The reboot ensures that any pending installs or updates don't hinder the Visual Studio install.

  4. 釋出空間。Free up space. 透過執行 [磁碟清理] 應用程式之類的方式,將不必要的檔案及應用程式從 %SystemDrive% 移除。Remove unneeded files and applications from your %SystemDrive% by, for example, running the Disk Cleanup app.

如有並存執行舊版 Visual Studio 及 Visual Studio 2019 的相關問題,請參閱 Visual Studio 2019 平台目標及相容性頁面。For questions about running previous versions of Visual Studio side by side with Visual Studio 2019, see the Visual Studio 2019 Platform Targeting and Compatibility page.

步驟 2:下載 Visual StudioStep 2 - Download Visual Studio

接下來,請下載 Visual Studio 啟動載入器檔案。Next, download the Visual Studio bootstrapper file. 若要這麼做,請依序選擇下列按鈕、您想要的 Visual Studio 版本、[儲存] 和 [開啟資料夾]。To do so, choose the following button, choose the edition of Visual Studio that you want, choose Save, and then choose Open folder.

步驟 3:安裝 Visual Studio 安裝程式Step 3 - Install the Visual Studio installer

執行啟動載入器檔案以安裝 Visual Studio 安裝程式。Run the bootstrapper file to install the Visual Studio Installer. 這個新輕量型安裝程式包含安裝及自訂 Visual Studio 所需的全部內容。This new lightweight installer includes everything you need to both install and customize Visual Studio.

  1. 從您的 [下載] 資料夾中,按兩下符合或類似於下列其中一項檔案的啟動載入器:From your Downloads folder, double-click the bootstrapper that matches or is similar to one of the following files:

    • vs_community.exe (適用於 Visual Studiofor Community)vs_community.exe for Visual Studio Community
    • vs_professional.exe (適用於 Visual Studio Professional)vs_professional.exe for Visual Studio Professional
    • vs_enterprise.exe (適用於 Visual Studio Enterprise)vs_enterprise.exe for Visual Studio Enterprise

    如果您收到使用者帳戶控制通知,請選擇 [是]。If you receive a User Account Control notice, choose Yes.

  2. 我們將會要求您認可 Microsoft 授權條款和 Microsoft 隱私權聲明We'll ask you to acknowledge the Microsoft License Terms and the Microsoft Privacy Statement. 選擇 [繼續]。Choose Continue.

步驟 4 - 選擇工作負載Step 4 - Choose workloads

安裝完畢之後,您可用它來選取自訂安裝工作負載,或功能集,您想要的。After the installer is installed, you can use it to customize your installation by selecting the workloads, or feature sets, that you want. 方式如下:Here's how.

  1. 在 [安裝 Visual Studio] 畫面中找到您想要的工作負載。Find the workload you want in the Installing Visual Studio screen.

    Visual Studio 2019:安裝工作負載

    CoreC++支援,請選擇 「 使用桌面開發C++「 工作負載。For core C++ support, choose the "Desktop development with C++" workload. 它隨附預設核心編輯器,其中包括超過 20 種語言的基本程式碼編輯支援、能夠從任何資料夾開啟及編輯程式碼而不需要專案,以及整合的原始程式碼控制。It comes with the default core editor, which includes basic code editing support for over 20 languages, the ability to open and edit code from any folder without requiring a project, and integrated source code control.

    其他工作負載都支援其他類型的C++開發。Additional workloads support other kinds of C++ development. 例如,選擇建立 Windows 執行階段用於 Microsoft Store 的應用程式的 「 通用 Windows 平台開發 」 工作負載。For example, choose the "Universal Windows Platform development" workload to create apps that use the Windows Runtime for the Microsoft Store. 選擇 「 遊戲開發使用C++"來建立使用 DirectX、 Unreal 及 Cocos2d 的遊戲。Choose "Game development with C++" to create games that use DirectX, Unreal, and Cocos2d. 選擇 「 使用的 Linux 開發C++「 目標 Linux 平台,包括 IoT 開發。Choose "Linux development with C++" to target Linux platforms, including IoT development.

    安裝詳細資料窗格會列出安裝的每個工作負載的包含和選擇性元件。The Installation details pane lists the included and optional components installed by each workload. 您可以選取或取消選取這份清單中的選用元件。You can select or deselect optional components in this list. 例如,如果使用來支援開發的 Visual Studio 2017 或 2015年編譯器工具組,選擇 MSVC v141 或 MSVC v140 選用元件。For example, to support development by using the Visual Studio 2017 or 2015 compiler toolsets, choose the MSVC v141 or MSVC v140 optional components. 您可以加入支援 MFC、 實驗性模組語言延伸模組、 IncrediBuild,等等。You can add support for MFC, the experimental Modules language extension, IncrediBuild, and more.

  2. 您選擇的工作負載和您想要的選用元件之後,請選擇安裝After you choose the workload(s) and optional components you want, choose Install.

    接著會出現狀態畫面,顯示 Visual Studio 的安裝進度。Next, status screens appear that show the progress of your Visual Studio installation.

提示

您可以在安裝後,隨時安裝一開始未安裝的工作負載或元件。At any time after installation, you can install workloads or components that you didn't install initially. 如果您已開啟 Visual Studio,請移至 [工具] > [Get Tools and Features] (取得工具和功能),以開啟 Visual Studio 安裝程式。If you have Visual Studio open, go to Tools > Get Tools and Features... which opens the Visual Studio Installer. 或者,從 [開始] 功能表開啟 [Microsoft Visual Studio 安裝程式]。Or, open Visual Studio Installer from the Start menu. 您可以在此選擇想要安裝的工作負載或元件。From there, you can choose the workloads or components that you wish to install. 然後,選擇 [修改]。Then, choose Modify.

步驟 5:選取個別元件 (選擇性)Step 5 - Choose individual components (Optional)

如果您不想要使用工作負載功能來自訂您的 Visual Studio 安裝,或您想要新增比工作負載所安裝元件的更多元件,您可以從 [個別元件] 索引標籤安裝或新增個別的元件來完成此作業。選擇您想要的項目,然後遵循提示作業。If you don't want to use the Workloads feature to customize your Visual Studio installation, or you want to add more components than a workload installs, you can do so by installing or adding individual components from the Individual components tab. Choose what you want, and then follow the prompts.

Visual Studio 2019 - 安裝個別元件Visual Studio 2019 - Install individual components

步驟 6:安裝語言套件 (選擇性)Step 6 - Install language packs (Optional)

根據預設,安裝程式會在第一次執行時,嘗試比對作業系統的語言。By default, the installer program tries to match the language of the operating system when it runs for the first time. 若要以您選擇的語言安裝 Visual Studio,請選擇 Visual Studio 安裝程式的 [語言套件] 索引標籤,然後遵循提示作業。To install Visual Studio in a language of your choosing, choose the Language packs tab from the Visual Studio Installer, and then follow the prompts.

Visual Studio 2019 - 安裝語言套件Visual Studio 2019 - Install language packs

從命令列變更安裝程式語言Change the installer language from the command line

另一個變更預設語言的方法,便是從命令列執行安裝程式。Another way that you can change the default language is by running the installer from the command line. 例如,您可以使用下列命令來強制安裝程式以英文執行:vs_installer.exe --locale en-USFor example, you can force the installer to run in English by using the following command: vs_installer.exe --locale en-US. 下一次執行時,安裝程式將會記住這項設定。The installer will remember this setting when it's run the next time. 安裝程式支援下列語言權杖:zh-cn、zh-tw、cs-cz、en-us、es-es、fr-fr、de-de、it-it、ja-jp、ko-kr、pl-pl、pt-br、ru-ru 和 tr-tr。The installer supports the following language tokens: zh-cn, zh-tw, cs-cz, en-us, es-es, fr-fr, de-de, it-it, ja-jp, ko-kr, pl-pl, pt-br, ru-ru, and tr-tr.

步驟 7 - 變更安裝位置 (選擇性)Step 7 - Change the installation location (Optional)

您可以減少系統磁碟機上的 Visual Studio 安裝磁碟使用量。You can reduce the installation footprint of Visual Studio on your system drive. 您可以選擇將快取、共用元件、SDK 和工具下載至不同的磁碟機,並將 Visual Studio 保留在以最快速度執行它的磁碟機上。You can choose to move the download cache, shared components, SDKs, and tools to different drives, and keep Visual Studio on the drive that runs it the fastest.

Visual Studio 2019 - 變更安裝位置Visual Studio 2019 - Change installation locations

重要

您只有在第一次安裝 Visual Studio 時才可以選取不同的磁碟機。You can select a different drive only when you first install Visual Studio. 如已安裝 Visual Studio 並想要變更磁碟機,您必須解除安裝它,再重新安裝。If you've already installed it and want to change drives, you must uninstall Visual Studio and then reinstall it.

步驟 8 - 開始開發Step 8 - Start developing

  1. 在完成 Visual Studio 安裝後,請選擇 [啟動] 按鈕以開始使用 Visual Studio 來進行開發。After Visual Studio installation is complete, choose the Launch button to get started developing with Visual Studio.

  2. 在開始視窗中,選擇 [建立新專案]。On the start window, choose Create a new project.

  3. 在搜尋方塊中,輸入您想要建立的應用程式類型,以查看可用的範本清單。In the search box, enter the type of app you want to create to see a list of available templates. 範本清單取決於您在安裝期間所選擇的工作負載。The list of templates depends on the workload(s) that you chose during installation. 若要查看不同的範本,請選擇不同的工作負載。To see different templates, choose different workloads.

    您也可以使用 [語言] 下拉式清單來篩選搜尋特定的程式設計語言。You can also filter your search for a specific programming language by using the Language drop-down list. 您也可以使用 [平台] 清單和 [專案類型] 清單篩選。You can filter by using the Platform list and the Project type list, too.

  4. Visual Studio 會開啟您的新專案,而您已準備好撰寫程式碼!Visual Studio opens your new project, and you're ready to code!

Visual Studio 2017 安裝Visual Studio 2017 Installation

在 Visual Studio 2017 中,很容易選擇並安裝您所需的功能。In Visual Studio 2017, it's easy to choose and install just the features you need. 因為降低了磁碟使用量下限,所以安裝快速,且對系統影響更小。And because of its reduced minimum footprint, it installs quickly and with less system impact.

必要條件Prerequisites

  • 寬頻網際網路連線。A broadband internet connection. Visual Studio 安裝程式可以下載好幾 gb 的資料。The Visual Studio installer can download several gigabytes of data.

  • 執行 Microsoft Windows 7 或更新版本的電腦。A computer that runs Microsoft Windows 7 or later versions. 我們建議的最佳開發體驗的 Windows 10。We recommend Windows 10 for the best development experience. 請確定您安裝 Visual Studio 之前,將最新的更新會套用到您的系統。Make sure that the latest updates are applied to your system before you install Visual Studio.

  • 足夠的可用磁碟空間。Enough free disk space. Visual Studio 至少需要 7 GB 的磁碟空間,而可能需要 50 GB 或更多如果安裝了許多常見的選項。Visual Studio requires at least 7 GB of disk space, and can take 50 GB or more if many common options are installed. 我們建議您將它安裝在您的 c: 磁碟機。We recommend you install it on your C: drive.

如需磁碟空間和作業系統需求的詳細資訊,請參閱Visual Studio 產品系列系統需求For details on the disk space and operating system requirements, see Visual Studio Product Family System Requirements. 安裝程式會報告您選取的選項需要多少磁碟空間。The installer reports how much disk space is required for the options you select.

下載並安裝Download and install

  1. 下載最新的 Visual Studio 2017 安裝程式的 Windows。Download the latest Visual Studio 2017 installer for Windows.

    提示

    Community Edition 是針對個別開發人員、課堂學習、學術研究和開放原始碼開發。The Community edition is for individual developers, classroom learning, academic research, and open source development. 針對其他用途,請安裝 Visual Studio 2017 ProfessionalVisual Studio 2017 EnterpriseFor other uses, install Visual Studio 2017 Professional or Visual Studio 2017 Enterprise.

  2. 尋找您已下載並執行它的安裝程式檔案。Find the installer file you downloaded and run it. 它可能會顯示在瀏覽器中,或您可能會發現您的 [下載] 資料夾中。It may be displayed in your browser, or you may find it in your Downloads folder. 安裝程式需要系統管理員權限,才能執行。The installer needs Administrator privileges to run. 您可能會看到使用者帳戶控制詢問是否要授與權限,讓安裝程式對您的系統進行變更; 選擇的對話方塊You may see a User Account Control dialog asking you to give permission to let the installer make changes to your system; choose Yes. 如果您遇到問題,請在檔案總管中尋找下載的檔案,以滑鼠右鍵按一下 [安裝程式] 圖示,然後選擇系統管理員身分執行從內容功能表。If you're having trouble, find the downloaded file in File Explorer, right-click on the installer icon, and choose Run as Administrator from the context menu.

    下載並安裝 Visual Studio InstallerDownload and install the Visual Studio Installer

  3. 安裝程式會顯示一份工作負載清單,而工作負載是特定開發區域的相關選項群組。The installer presents you with a list of workloads, which are groups of related options for specific development areas. 支援C++現在是選擇性的工作負載,並未預設安裝的一部分。Support for C++ is now part of optional workloads that aren't installed by default.

    使用的桌面開發C++工作負載Desktop development with C++ workload

    針對C++,選取使用的桌面開發C++ 工作負載,然後選擇安裝For C++, select the Desktop development with C++ workload and then choose Install.

    安裝使用的桌面開發C++工作負載Install the Desktop development with C++ workload

  4. 當安裝完成時,選擇啟動按鈕來啟動 Visual Studio。When the installation completes, choose the Launch button to start Visual Studio.

    第一次執行 Visual Studio 中,系統會詢問的 Microsoft 帳戶登入。The first time you run Visual Studio, you're asked to sign in with a Microsoft Account. 如果您沒有帳戶,您可以免費建立一個。If you don't have one, you can create one for free. 您也必須選擇一個佈景主題。You must also choose a theme. 別擔心,您可以將它變更稍後如果您想要。Don't worry, you can change it later if you want to.

    可能需要 Visual Studio 幾分鐘,您就準備好使用您在執行第一次。It may take Visual Studio several minutes to get ready for use the first time you run it. 以下是看起來像是快速縮時攝影外:Here's what it looks like in a quick time-lapse:

    登入的 visual Studio 2017Visual Studio 2017 sign in

    當您一次執行時,visual Studio 的啟動速度更快。Visual Studio starts much faster when you run it again.

  5. Visual Studio 開啟時,請查看標題列中的旗標圖示會反白顯示:When Visual Studio opens, check to see if the flag icon in the title bar is highlighted:

    Visual Studio 2017 通知 旗標Visual Studio 2017 notification flag

    如果會反白顯示,請選取它以開啟通知視窗。If it's highlighted, select it to open the Notifications window. 如果有適用於 Visual Studio 的任何更新,我們建議您立即安裝它們。If there are any updates available for Visual Studio, we recommend you install them now. 安裝完成之後,重新啟動 Visual Studio。Once the installation is complete, restart Visual Studio.

Visual Studio 2015 安裝Visual Studio 2015 Installation

若要安裝 Visual Studio 2015,請前往下載舊版 Visual StudioTo install Visual Studio 2015, go to Download older versions of Visual Studio. 執行安裝程式,並選擇 [自訂安裝],然後選擇 C++ 元件。Run the setup program and choose Custom installation and then choose the C++ component. 若要新增C++支援新增至現有的 Visual Studio 2015 安裝,請按一下 Windows [開始] 按鈕並鍵入新增或移除程式To add C++ support to an existing Visual Studio 2015 installation, click on the Windows Start button and type Add Remove Programs. 從結果清單中開啟的程式,然後尋找 Visual Studio 2015 安裝在已安裝的程式清單中。Open the program from the results list and then find your Visual Studio 2015 installation in the list of installed programs. 連按兩下,然後選擇修改,然後選取視覺效果C++若要安裝的元件。Double-click it, then choose Modify and select the Visual C++ components to install.

一般來說,即使需要使用 Visual Studio 2015 編譯器,編譯您的程式碼,也都非常建議您使用 Visual Studio 2017。In general, we highly recommend that you use Visual Studio 2017 even if you need to compile your code using the Visual Studio 2015 compiler. 如需詳細資訊,請參閱在 Visual Studio 中使用原生多目標來建置舊專案For more information, see Use native multi-targeting in Visual Studio to build old projects.

當 Visual Studio 執行時,您即可繼續下一個步驟。When Visual Studio is running, you're ready to continue to the next step.

後續步驟Next Steps