Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Compiling a program for a 64 bit machine on a 32 bit machine.

indurks
Beginner
281 Views
Hello, I have a 32 bit laptop with a Intel Pentium M processor.

I have the Intel C++ 10.1 compiler installed on Debian Linux.

I want to compile a program and run it on a 64 bit machine:
Intel Xeon CPU, X5355 @ 2.66GHz

I can't for the life of me find the compiler flags I need. Here are the ones I have so far:

-Wp64 -Ap64 -As64

(I've been trying everything).

If someone could help me, this would be a huge help as I've been banging my head way too long looking for the correct flag.

I've been able to compile for the 64 bit machine before by using the -xT flag, but the 64 bit machine executes the program as a 32 bit program (so sizeof(void*) == 4 instead of 8).
0 Kudos
1 Reply
TimP
Honored Contributor III
281 Views

Yes, if you compile with the 32-bitcompiler, and provide all required .so, you can run on both 32- and 64-bit OS in 32-bit mode. -xT is certainly not required, although all recent x86-64 systems support at least -xO (-xW for early AMD). 64-bit cross compilation on 32-bit linux is possible in principle, but not supported. For starters, you would have to copy over a bunch of libraries from a 64-bit linux installation, and you would have to set up some version of gcc/g++ cross compiler, at least to the extent that icc finds the 64-bit libraries when it asks g++ where to find them, and finds a cross linker.Given that cross compilation for 64-bit from 32-bit linux hasn't been supported, icc-64 will change soon to a 64-bit compiler, eliminating the slight possibility of cross compilation.

Intel and others found out several years ago that there is little demand for building 64-bit applications on a 32-bit system, and the designers of the x86_64 OS never attempted to facilitate cross compilation (except for the other direction).

0 Kudos
Reply