User forums > Using Code::Blocks

[SOLVED]How to define different custom compilers for 64bit only?

(1/2) > >>

cacb:
I have a C++ library (not written by me) to be compiled using the MSVC compiler and which needs an *.asm file to be compiled when using the 64bit toolchain, but not when using the 32bit toolchain.

I have been able to define a C::B custom compiler that works for *.asm when compiling in 64bit mode (see attachment). However it also runs if I compile in 32bit mode, and I wonder if there is a way to prevent that happening as it causes conflicts in linking.

The way I control 32bit vs 64bit is by using C::B global variables to define the Toolchain search paths. Could I make it work by defining a TOOLCHAIN.ASM field and set it to ml64.exe for the 64bit case and something that does nothing in the 32bit case? Are the advanced compiler options able to understand user defined global variables? Or is there a better way?

Platform: Win7 C::B svn 10376

scarphin:
Maybe you can define 2 different compilers (1 for 32bit, 1 for 64bit) and assign your targets with the corresponding compiler.

cacb:

--- Quote from: scarphin on December 19, 2015, 02:22:03 am ---Maybe you can define 2 different compilers (1 for 32bit, 1 for 64bit) and assign your targets with the corresponding compiler.

--- End quote ---

I don't differentiate between 32bit and 64bit targets explicitly in the project files. Instead I have global variable sets that are defined for 32bit and 64 bit toolchains. So switching between 64bit and 32bit is simply done just by selection the current global variable set and then recompile.

In this particular case, the *.asm file is to be compiled only for the 64bit case, not for the 32bit case. I will try my original idea and see if it works.

cacb:
I have tried various things and I cannot make it work. I can make it work for either 64 or 32 bit but not for both. The problem seems to be that
- in the 64bit case the *.asm file MUST be assembled using asm64.exe and the *.obj included in the static lib
- in the 32bit case the *.asm file MUST be excluded

Is there some way to conditionally compile/link a project file, based on the value of a global variable? Ideas welcome.

MortenMacFly:

--- Quote from: cacb on December 19, 2015, 07:00:00 pm ---Is there some way to conditionally compile/link a project file, based on the value of a global variable? Ideas welcome.

--- End quote ---
Why make it so complicated? Make 2 targets in the project, one for 64, one for 32 bit. Setup different compilers for them, then assign the files to be compiled as needed. Thus,. for the 32 bit exclude the ASM files, for 64 bit don't.

Navigation

[0] Message Index

[#] Next page

Go to full version