Johan
Johan

Reputation: 3190

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

Upvotes: 6

Views: 11391

Answers (4)

Romil
Romil

Reputation: 51

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

Upvotes: 5

Laurent Parenteau
Laurent Parenteau

Reputation: 2576

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 :

Upvotes: 6

MarkR
MarkR

Reputation: 63538

You'd need to set up a cross compiler. And don't bother. Just run a 64-bit VM instead. You can run 64-bit VMs on a 32-bit host OS provided the CPU supports it (which it will, unless it's ancient).

Upvotes: -1

Paul R
Paul R

Reputation: 212929

Yes, this should be possible. It's certainly possible on Mac OS X, where Apple's gcc toolchain supports x86, x86-64, ppc and ppc64, and you can compile for all 4 targets from a development machine that is 32 bit or 64 bit.

Upvotes: 3

Related Questions