User forums > Using Code::Blocks

Using different MSVC compiler versions for same C::B target

(1/1)

cacb:
Hi,

One of the really excellent features of Code::Blocks is the use of global variables to handle different compiler paths, library paths etc.

I have C::B projects using MSVC compiler on Windows. I have VC2008 installed. When I investigate the C::B project files I find the following in my Windows build targets

--- Code: ---<Option compiler="msvc8" />
--- End code ---

However, a friend wants to build the same code using his installed VC2010 compiler. The only way we got it to work was by performing a text search/replace to

--- Code: ---<Option compiler="msvc10" />
--- End code ---

Then all is well, except we cannot share project files (I am not going to upgrade my compiler, for various reasons).

Is there some way we can improve this, for example using global variables? We tried this

--- Code: ---<Option compiler="$(#CPDE_COMPILER)" />
--- End code ---

Hoping that CPDE_COMPILER would be understood as a global variable that we could set to msvc8 and msvc10 respectively. But it seems global variables are not recognised in this context?

We also tried removing the option completely (assuming our default compilers would be used), but that didn't work either.

Any Ideas how to handle this?

oBFusCATed:
Two solutions:
1. you duplicate the target, so your project has vc9 and vc10 targets
2. use commonly named compiler -> msvc for example...

cacb:

--- Quote from: oBFusCATed on March 16, 2011, 12:53:03 pm ---Two solutions:
1. you duplicate the target, so your project has vc9 and vc10 targets
2. use commonly named compiler -> msvc for example...

--- End quote ---

Interesting.
Solution 1 is not acceptable, as it doubles the amount of project maintenance.

Solution 2 seems like the way to go, but I need some more details on exactly how to do it. Do you mean that we both edit our default.conf files so that we get a generically named msvc compiler instead of a specific one?
msvc8 => msvc
msvc10 => msvc

If there is no caveats here, it seems like a general enough solution!

Jenna:

--- Quote from: cacb on March 16, 2011, 02:09:02 pm ---Solution 2 seems like the way to go, but I need some more details on exactly how to do it. Do you mean that we both edit our default.conf files so that we get a generically named msvc compiler instead of a specific one?
msvc8 => msvc
msvc10 => msvc

If there is no caveats here, it seems like a general enough solution!

--- End quote ---

Just copy the used compiler to a new one named "MSVC" in "Settings -> Compiler and debugger -> General compiler settings" on both systems.
In default.conf they will be called msvc in both cases.
So it should work without hacking default.conf directly.

cacb:

--- Quote from: jens on March 16, 2011, 02:26:15 pm ---Just copy the used compiler to a new one named "MSVC" in "Settings -> Compiler and debugger -> General compiler settings" on both systems.
In default.conf they will be called msvc in both cases.
So it should work without hacking default.conf directly.

--- End quote ---

Thank you! That seems to work!  :D

Navigation

[0] Message Index

Go to full version