简体   繁体   中英

How to compile GCC for android?

Is there any way to compile GCC for android? Basically, have the GCC compiler accessible in an android terminal emulator and able to compile a binary that will run on android from a C or C++ source file.

My intention is to use this and eventually install make.

The Android NDK already includes the complete GNU toolchain which runs on your computer. You should be able to use it to compile native versions of whatever program you want.

In the NDK, see docs/STANDALONE-TOOLCHAIN.html for setting up the cross-compiler. You probably want to follow the steps for "Invoking the compiler (the easy way)" to set up a copy of the toolchain which you should be able to use with configure scripts commonly included with GNU applications (like gcc).

This really is a non-trivial task and I recommend you read the docs very carefully. It also contains various values for CFLAGS, LDFLAGS etc. that you will need to customize and use when configuring and compiling your programs.

As for compiling gcc, make, etc., themselves, it's probably not necessary or desirable to do so. gcc, for instance, is going to be huge and you may not have enough storage on the phone to install it. If your ultimate intention is to compile some program to run natively on the Android device, then I would recommend you just use the NDK and point the app's configure script at it.

You can download the GCC toolchain for Android here:

Android gcc 4.4.0

There is also GCC plugin for the C4Droid app available on the Google Play. However it is paid app it is very cheap. Free option should be Terminal IDE posted in this answer https://stackoverflow.com/a/15865001/881375 it just looks heavy as the size suggests.

Update: The KBOX app, which runs in a terminal emulator app on Android, has gcc 4.7 and 4.8 available. Details and downloads can be found here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM