Author Topic: Configuring Code::Blocks using Visual Studio 2019 compiler (MSVC)  (Read 652 times)

Offline cacb

  • Regular
  • ***
  • Posts: 425
I have recently installed Visual Studio 2019 Enterprise Under Windows 10 and configured it for use in Code::Blocks under the generic name 'MSVC'. My projects all refer to a generic 'MSVC' compiler on Windows. This way the project files are unaffected by a compiler upgrade from MSVC2013 to MSVC2019 (or any other combination of compiler versions). The user defined MSVC compiler relies on definitions in C::B global variables to make things easier and avoid repetition.

There is a quick writeup for MSVC2019 configuration at this address

I still have MSVC2013 installed, and I am able to switch between these compilers using the 'cb_config' tool found in . It works by editing the C::B XML configuration file default.conf. C::B must obviously be closed when this happens so 'cb_config' refuses to do anything if C::B is running.

Switching between MSVC2013/MSVC2019 compilers means to overwrite the definition of the MSVC user defined compiler with settings from either MSVC2013 or MSVC2019 - also user defined compilers. Typically different sets of global variables goes along with each compiler so the corresponding global variable set should be activated at the same time, so this can also be done in 'cb_config'.

In theory you could do these things from within C::B, but changing active global variable set has always been a bit confusing, it does not seem to be activated 100% unless you close and restart C::B. Redefining 'MSVC' to contain definitions for a specific compiler version is impractical if you need to switch back and forth, doing it using the 'cb_config' tool is much easier for my setup.

It would be nice to have these capabilities integrated into the C::B GUI, but using 'cb_config' seems to work fine for now. If you need only MSVC2019, the writeup above should be sufficient.

Offline sodev

  • Regular
  • ***
  • Posts: 382
Re: Configuring Code::Blocks using Visual Studio 2019 compiler (MSVC)
« Reply #1 on: January 14, 2020, 03:23:29 pm »
The usage of global variables to store toolchain related information is a really nice idea, actually i didn't know that these can be used in these locations. This should help a lot to deal with changing version numbers because of frequent updates, i am going to use that approach to improve my workflow :).

I am also using different MSVC versions/variants with CodeBlocks but i use a different approach, i am using "tagged" variables and compilers. I have multiple compiler definitions like msvc140_xp, msvc142_x86 together with global variables for external libraries like boost_vc142_x86, wx31_vc142_x86. However i am not using handwritten Project Files but generate them with a heavily modified Premake 3.x. With this setup i just have to specify the comiler during the generation and don't have to change anything in CodeBlocks when i switch to different projects.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2730
Re: Configuring Code::Blocks using Visual Studio 2019 compiler (MSVC)
« Reply #2 on: January 14, 2020, 07:56:35 pm »
You can use global variables nearly everywhere... Sadly this also slows down the compiling process quite a bit...