如何将CodeBlocks与VC ++编译器的最新版本一起使用?

asa*_*sam 4 compilation codeblocks visual-c++

我需要在最新版本的MS VC ++编译器中使用C :: B,例如VS2015或VS2017中的版本,并最终在将来的版本中使用,但是C :: B不提供此类选项。C :: B允许用户从其列表中的“设置”中选择的最新VC ++版本是非常古老的VC ++ 2010(MSVC ++ 10.0)。经过一番搜索,我没有找到解决该问题的解释。甚至C :: B网站也没有提供解决方案。我怎样才能做到这一点?

asa*_*sam 5

在使用C :: B设置和VC ++编译器进行了一些尝试之后,我发现了一个根本不复杂的解决方案。在这篇文章中,我将展示如何通过CodeBlocks使用最新版本的VC ++编译器(MSVC ++ 14.0或更高版本)-无需安装Visual Studio。如果您更喜欢使用Visual Studio,则解决方案将相同。
我将回答32位和64位项目的问题。默认情况下它将支持std C ++ 14。内容:A)安装最新版本并针对x86项目进行编译;B)更改为C :: B 64位项目。

A)安装并用于32位项目

  1. 安装最新版本的VC ++编译器。可以通过NuGet获得VC ++工具集。要获取NuGet,请查看此处:NuGet。从命令行运行以下命令。该命令安装的最新版本是(根据MSDN):
    c:\\> nuget install VisualCppTools.Community.Daily.VS2017Layout -Version 14.14.26423-Pre -Source https://visualcpp.myget.org/F/dailymsvc/api/v3/index.json

  2. 安装Microsoft Build Tools 2015(或更高版本)。在这里,我将坚持使用2015,但您可以选择在2017
    年使用。对于2015,安装程序在此处BuildTools2015。运行它以安装工具。

  3. 打开C :: B并进行配置。C :: B Microsoft Visual C ++的最新版本是2010。我们可以使用它,但要设置一个更新的编译器。

    3.1转到设置>>编译器

    3.2在“选定的编译器”中,选择MS visual C ++2010。这是C :: B中可用的更高版本。

    3.3 Select the Tab "Toolchain executables" and set the Compiler's directory with the directory with the VC++ Toolset. In my case:
    D:\VisualCppTools.14.0.25114-Pre\lib\native Confirm if the "Program Files" boxes of the tab are filled.

    3.3 Select "Search directories" tab. 3.3.1 In "Compiler" tab add the include directory path. In my case is:
    D:\VisualCppTools.14.0.25114-Pre\lib\native\include

    Possibly the following will also be needed (from Build Tools).
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
    Also if not already there and if needed (in my case)
    C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um

    3.3.2 In "Linker" tab enter the paths for the libs. In my case.
    D:\VisualCppTools.14.0.25114-Pre\lib\native\lib Possibly, also,
    C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x86 And if your project complains about uuid.lib, then insert also (in my case),
    C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86

    3.3.3 "Resource compiler" tab. This is optional. In my case,
    D:\VisualCppTools.14.0.25114-Pre\lib\native\include

And that's it! But if we prefer, C::B allow us to change the compiler name.

B) Change the C::B project settings for x64 projects

  1. Point linker libraries' paths to their x64 counterparts. In the Settings menu choose "Search Directories">>"Linker".

    1.1 For the compiler library, add "amd64". In my case:
    D:\VisualCppTools.14.0.25114-Pre\lib\native\lib\amd64

    1.2 For "ucrt" and "um" add "\x64" to the paths. Example for my case:
    C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64 C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64

  2. For the compiler select the Tab "Toolchain executables" and insert the prefix "amd64\" for C++ compiler and Make program, as: amd64\cl.exe, amd64\nmake.exe

Again, that's it!

Good work!