[SOLVED] How can I compile a .c or .cpp file and let it run on my phone?
Linux - MobileThis forum is for the discussion of all topics relating to Mobile Linux. This includes Android, Tizen, Sailfish OS, Replicant, Ubuntu Touch, webOS, and other similar projects and products.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Just because you compile some code for an ARM CPU, doesn't necessarily mean that code will execute as-is on Android. Any more than it'll execute as-is on Windows CE (which also supports ARM).
Yes, you can compile C++ code to run under Android. To do this, you need to download the Android NDK:
Frankly, though, this is several orders of magnitude more difficult than simply using the (Java) SDK. I would strongly encourage to you try using Java first, and C++ only as a last resort, if you absolutely have to. Here's where you can find the current SDK:
Actually Android is not really linux. Android is a java OS which happens to run linux as a kernel but it is not exposed. You can't compile a binary for it that is executed by the linux kernel directly.
If you want a true mobile GNU/linux system, you should give Maemo a try.
And even Chrome OS is more like Linux than Android; just look at Wikipedia's Google Chrome OS article for details. It includes a package manager, GNU coreutils, GCC, and even X, unlike Android.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.