如何将CodeBlocks与VC ++编译器的最新版本一起使用? [英] How can I use CodeBlocks with the most recent versions of the VC++ compiler?
问题描述
我需要在MS VC ++编译器的最新版本中使用C :: B,例如VS2015或VS2017中的版本,并最终在将来的版本中使用,但是C :: B不提供此类选项。 C :: B允许用户从其列表中的设置中选择的最新VC ++版本是非常古老的VC ++ 2010(MSVC ++ 10.0)。经过一番搜索,我没有找到解决该问题的解释。甚至C :: B网站也没有提供解决方案。我该怎么做?
I need to use C::B with a recent version of MS VC++ compiler like the ones in VS2015 or VS2017, and eventually future ones, but C::B does not offer such option. The most recent VC++ version that C::B allows the user to choose from its list, in the Settings, is VC++2010 (MSVC++10.0) wich is quite old. After some search I didn't find an explanation to overcome the problem. Not even C::B site offers a solution. How can I do that?
推荐答案
在我使用C :: B设置和VC ++编译器进行了一些尝试之后,我找到了解决方案一点也不复杂。在这篇文章中,我将展示如何通过CodeBlocks使用最新版本的VC ++编译器(MSVC ++ 14.0或更高版本)-无需安装Visual Studio。如果您更喜欢使用Visual Studio,则解决方案相同。
我将回答32位和64位项目的问题。默认情况下它将支持std C ++ 14。
内容:
A)安装最新版本并针对x86项目进行编译;
B)更改为C :: B 64位项目。
After some attempts I made with C::B settings and VC++ compilers, I found a solution that is not complicate at all. In this post I will show how to use the latest versions of VC++ compiler (MSVC++ 14.0 or higher) with CodeBlocks - with no need to install Visual Studio. The solution would be identical if you prefer to use Visual Studio instead.
I will answer the question for 32 and 64 bits projects. By default it will support std C++14.
Content:
A) Install the latest version and compile for x86 projects;
B) Change to C::B 64bits projects.
A)安装和使用32位项目
A) Install and use for 32bits projects
-
安装最新版本的VC ++编译器。
可以通过NuGet获得VC ++工具集。
要获取NuGet,请在此处: NuGet 。
从命令行运行以下命令。该命令安装的最新版本是(根据 MSDN ):
c:\\ > nuget安装VisualCppTools.Community.Daily.VS2017Layout-版本14.14.26423-Pre-源https://visualcpp.myget.org/F/dailymsvc/api/v3/index.json
安装Microsoft Build Tools 2015(或更高版本)。在这里,我会坚持使用2015,但您可以选择在2017年使用。
对于2015,安装程序在此处 BuildTools2015 。运行它来安装工具。
Install Microsoft Build Tools 2015 (or higher). Here I will stick with 2015, but you can go for 2017.
For 2015 the installer is here BuildTools2015. Run it to install the tools.
打开C :: B并进行配置。 C :: B Microsoft Visual C ++的最新版本是2010。我们可以使用它,但要设置一个更新的编译器。
Open C::B and configure it. C::B last version for Microsoft Visual C++ is 2010. We can use it, but seting a more recent compiler.
3.1转到设置 >>编译器
3.1 Go to Settings>>Compiler
3.2在选定的编译器中,选择MS visual C ++2010。这是C :: B中可用的更高版本。
3.2 In "Selected Compiler" select MS visual C++ 2010. This is the higher version available in C::B.
3.3选择工具链可执行文件选项卡,并使用VC ++工具集的目录设置编译器的目录。在我的情况下:
D:\VisualCppTools.14.0.25114-Pre\lib\native
确认选项卡的文件框中。
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选择搜索目录选项卡。
3.3.1在编译器选项卡中,添加包含目录路径。
我的情况是:
D:\VisualCppTools.14.0.25114-Pre\lib\native\include
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
可能也需要以下内容(通过构建工具)。
C:\Program Files(x86)\ \Windows套件\10\包含\10.0.10240.0\ucrt
如果还不存在,并且需要(在我的情况下)
C:\程序文件(x86)\Windows套件\8.1\Lib\winv6.3\um
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在链接器选项卡中,输入库的路径。就我而言。
D:\VisualCppTools.14.0.25114-Pre\lib\native\lib
另外,
C:\Program Files(x86)\Windows套件\10\Lib\10.0.10240.0\ucrt\x86
如果您的项目抱怨uuid.lib,则还要插入(以我为例),
C:\Program Files(x86)\Windows Kits\8.1\Lib\winv6.3\um\x86
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资源编译器选项卡。这是可选的。就我而言,
D:\VisualCppTools.14.0.25114-Pre\lib\native\include
3.3.3 "Resource compiler" tab. This is optional. In my case,
D:\VisualCppTools.14.0.25114-Pre\lib\native\include
就是这样!但是如果愿意,可以使用C :: B来更改编译器名称。
And that's it! But if we prefer, C::B allow us to change the compiler name.
B)更改x64项目的C :: B项目设置
B) Change the C::B project settings for x64 projects
-
将链接程序库的路径指向x64副本。在设置菜单中选择搜索目录 >>链接器。
Point linker libraries' paths to their x64 counterparts. In the Settings menu choose "Search Directories">>"Linker".
1.1对于编译器库,添加 amd64。在我的情况下:
D:\VisualCppTools.14.0.25114-Pre\lib\native\lib\amd64
1.1 For the compiler library, add "amd64". In my case:
D:\VisualCppTools.14.0.25114-Pre\lib\native\lib\amd64
1.2对于 ucrt和 um,在路径中添加 \x64。我的案例示例:
C:\Program Files(x86)\Windows套件\10\Lib\10.0.10240.0\ucrt\x64
C:\Program Files(x86)\Windows Kits\8.1\Lib\winv6.3\um\x64
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
对于编译器,选择工具链可执行文件选项卡,并为C ++编译器和Make程序插入前缀 amd64\,例如:amd64\ \cl.exe,amd64\nmake.exe
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
再次,就是这样!
做得好!
这篇关于如何将CodeBlocks与VC ++编译器的最新版本一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!