How can I use CodeBlocks with the most recent versions of the VC++ compiler?

后端 未结 2 397
情深已故
情深已故 2021-02-06 12:47

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

相关标签:
2条回答
  • 2021-02-06 13:17

    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) Install and use for 32bits projects

    1. Install the latest version of VC++ compiler. The VC++ Toolset can be obtained through NuGet. To get NuGet look here: NuGet. Run the following command from the command line. The command installs the latest version is (according 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. 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.

    3. 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 Go to Settings>>Compiler

      3.2 In "Selected Compiler" select MS visual C++ 2010. This is the higher version available in 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!

    0 讨论(0)
  • 2021-02-06 13:20

    Below are compiler options entries for MSVC 2015 installation on Windows 7 when compiling a "plain" C++ console application (no CLI) for a x86 target machine:

    INCLUDE=
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
    C:\Program Files (x86)\Windows Kits\8.1\Include\um
    C:\Program Files (x86)\Windows Kits\8.1\Include\shared
    C:\Program Files (x86)\Windows Kits\8.1\Include\winrt
    
    LIB [x86]=
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\lib
    C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x86
    C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86
    C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Lib\um\x86
    
    LIBPATH=
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\lib
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib
    

    I added INCLUDE and LIB to search directories for compiler and linker, respectively, and everything worked in C::B for a x86 console application. I didn't experiment with x64 architecture...

    0 讨论(0)
提交回复
热议问题