C ++ that generates object code for two different machines

Are there C ++ compilers that I can run on a brand x system that will generate machine code that will work on a brand y system? Will this be considered a cross compiler?

+2


source to share


4 answers


Yes, that's exactly what cross compiler is .

The GNU Compiler Collection (including gcc and g ++) is a prime example of a portable cross-compiler with hundreds of supported processor types.



There are many ways to set up GCC as a cross compiler. Most of them depend on the target machine and what is available from it - mainly due to the C runtime. For example, compiling GCC for an ARM Linux target requires a pre-compiled glibc for ARM Linux to build the libstdC ++ cross compiler.

+10


source


This is quite common using gcc.

There are many tutorials out there to help you create your own cross-compiler environment. It is , but a quick Google will probably provide the link to someone doing exactly what you need.



edit: This is a more thorough guide using crosstool

+2


source


Yes, it is cross-compiled (although I would say "brand X" is not an appropriate classification term).

+1


source


Yes, there are such compilers; yes they are called cross compilers. For example, GCC can be configured so that I can run the compiler on a 32-bit x86 system, but produce 64-bit code on an x64 system, and that's just the tip of the iceberg.

Crosstool is a really handy set of tools for building cross-compiling GCC.

NTN,

Eric Melsky

Electric Cloud, Inc.

+1


source







All Articles