Question

Can I compile files (e.g. C or C++ source code) using for my android device using the arm-linux-gnueabi-* toolchain?

My question might seem a bit silly, but will I get the same result as compiling with the arm-linux-androideabi-* toolchain?

Was it helpful?

Solution

A compilation might mean more than just converting source code to binary. A compiler like GCC also provides certain libraries, in this case libgcc for handling what hardware can't handle. When a compiler becomes a toolchain, it also provides runtime libraries standardised by the programming language similar to ones provided in target system. In arm-linux-gnueabi-'s case that might be libc and for arm-linux-androideabi- that's bionic.

You can produce compatible object files to be used by different compilers, that's what elf is for.

You can produce static executable which can be mighty in size and they should work on any matching hardware/kernel, because in that case toolchains aim for that.

But if you produce dynamic executables, those ones can only run on systems that's supporting their dependencies. Because of that a simple "hello world" application that's not static build by arm-linux-gnueabi- won't work on an Android system since it provides bionic, not libc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top