How to compile a code for 32-bit machine on a 64-bit machine?

How to compile a code for 32-bit machine on a 64-bit machine?

Hi,

I'm using prallel studio, which includes the intel C++ compiler itself. I'm a windows user, and my system is 64-bit. I want to compile a code on my computer for a 32-bit computer. I mean that I want to run the binary, on a 32-bit system.

Would you please help me that what compiler options I should use? ( I compile my source codes from command line in windows. )

Thanks.

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

>>...I'm using prallel studio, which includes the intel C++ compiler itself...
.
Do you have a 32-bit or 64-bit version? For 32-bit binaries you need to use a 32-bit Intel C++ compiler.

Oh! you mean it depends on the version of the compiler? I thought there should be a compiler option which can choose between 32/64 bit systems. So you mean to compile the code for 32 bit machine I must have intel 32 bit version compiler?
thanks.

Yes, you need the 32-bit compiler to build a 32-bit application. If you are on linux or mac, you must install a working 32-bit g++ before installing icc for ia32. On a 64-bit linux or mac OS you could install 64-bit g++ alone or together with the 32-bit one. If the -m32 option works, it simply switches you over to the 32-bit tools, if they are installed. For Windows Visual Studio 2010 or 2012, the 32- and 64-bit Microsoft compilers are installed together, but in separate folders.

>>...I thought there should be a compiler option which can choose between 32/64 bit systems.
.
Unfortunately there is no an option to do this. Microsoft also uses different C++ compilers for different platforms.

To invoke the 32-bit compiler on Windows you can either open a 32-bit command prompt from the Parallel Studio XE or C++ Composer XE program group under "Command Prompt-->Parallel Studio XE with Intel Compiler XE v13.0-->IA-32 Visual Studio 2010 mode" or the one for VS2012 or VS2008. Invoking icl.exe in that command window will use the 32-bit compiler and libraries. You can also set up your own build environment for 32/64 by using the compilervars.bat as shown below:

c:\Program Files (x86)\Intel\Composer XE 2013\bin>compilervars
Syntax:
compilervars.bat [vs]

must be is one of the following
ia32 : Set up for IA-32 host and target
ia32_intel64 : Set up for IA-32 host and Intel(R)64 target
intel64 : Set up for Intel(R) 64 host and target
If specified, must be one of the following
vs2008 : Set to use Microsoft Visual Studio 2008
vs2008shell : Set to use Microsoft Visual Studio Shell 2008
vs2010 : Set to use Microsoft Visual Studio 2010
vs2010shell : Set to use Microsoft Visual Studio Shell 2010
vs2012 : Set to use Microsoft Visual Studio 2012
vs2012shell : Set to use Microsoft Visual Studio Shell 2012
If is not specified, the version of Visual Studio detected at install
time is used.

Login to leave a comment.