I understand what are cross compilers and why are they used. But in an interview I was asked that in what ways cross compilers are different from the normal compilers. I told them the purpose of the cross compilers. Also, the memory map will be different for them. But the g开发者_如何转开发uy does not seems to be convinced. Can any one tell me the basic differences from normal compilers?
A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is run. Cross compiler tools are used to generate executables for embedded system or multiple platforms. It is used to compile for a platform upon which it is not feasible to do the compiling, like microcontrollers that don't support an operating system. It has become more common to use this tool for paravirtualization where a system may have one or more platforms in use. - WIKI
according to some sources you cant just say java (or any others uses runtime environment or virtual machines) as cross compilers.
really cross compilers can target many platforms from one source code. but you may have to build each of them separately
A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is run.
A normal compiler can be a cross compiler. Take GCC for example.
Quoting from Wikipedia:
GCC, a free software collection of compilers, can be set up to cross compile. It supports many platforms and languages. However, due to limited volunteer time and the huge amount of work it takes to maintain working cross compilers, in many releases some of the cross compilers are broken.[citation needed]
GCC requires that a compiled copy of binutils be available for each targeted platform. Especially important is the GNU Assembler. Therefore, binutils first has to be compiled correctly with the switch --target=some-target sent to the configure script. GCC also has to be configured with the same --target option. GCC can then be run normally provided that the tools, which binutils creates, are available in the path.
The main difference is that with a "normal compiler" you can run the compiled executable right on the machine you compiled it on. With a cross compiler you will have to upload it to a system using its targetted platform somehow to run it and see if it works. (Or use some kind of emulator or VM).
That's the only big difference, really. It adds an extra step or two in your edit-compile-debug cycle. It can be a bit of a pain. Then again, typically cross-compilers are used for realtime or embedded systems where a likely result from a bug is a total system crash. If that can happen, it would be more of a pain to run on your development system, as you'd be constantly having to wait for reboots and restart your editor, reload working files into your editor, etc.
Some cross-compilers have pluggable code generators, so you simply indicate that type of code you want generated and they will look up the appropriate generator and invoke the proper assembler for the target you specify. For the most part, though, a compiler's a compiler; they all do the same thing.
I think the cross-compiler use different assembly language code. for example, the i386 and arm use different assembly language code.
精彩评论