Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set up a gcc cross compiler on Linux to compile 64 bit targets on a 32 bit architecture?

I know you can compile to a 32 bit target on 64 bit Linux by using the -m32 flag, but is it also possible to compile to 64 bit on a 32 bit machine by using the -m64 flag?

Or alternatively, do you need to set up a cross gcc tool chain that supports 64 bit targets and is this possible on a 32 bit machine?

Regards, Johan

like image 370
Johan Avatar asked Mar 01 '10 13:03

Johan


2 Answers

As MarkR said, it will be a lot easier to run a 64-bit VM and build from there. Otherwise, yes, you will need to build a gcc cross toolchain.

Good ressources for building a gcc cross toolchain :

  • Building and Testing gcc/glibc cross toolchains
  • GCC Cross-Compiler
  • Cross Compiling With GCC
like image 76
Laurent Parenteau Avatar answered Sep 28 '22 17:09

Laurent Parenteau


yes, its possible and actually quite simple. Just install gcc-multilib.

like image 33
Romil Avatar answered Sep 28 '22 18:09

Romil