GCC make for Android? - General Questions and Answers

Hello everyone. I'm looking for a way to use gcc make natively on Android. I know would supposedly be slow and heat up my cpu, but I don't get enough time on my computer to develop via a cross compiler.
Something like this would be ideal:
http://forum.xda-developers.com/showthread.php?t=1645182
I'd post there asking about a download link but the forums won't let me until I've made ten posts.
If anyone has any ideas how to get this working I'd love to hear them!

I found a gcc binary here:
rwiki.sciviews.org/doku.php?id=getting-started:installation:android
I don't know what version it us but it seems to run. I think I will try compiling gcc from scratch.
Can bionic libc be replaced with the full version of libc? Or would that break things?
Next up I think I'll try to get bash on this phone.
I'll post an update when I have gcc fully working.

I've found an app that does most of what I needed, called Terminal IDE on the play store. I now have a mostly functional development environment on my phone.
Next up, some of the open source software I want to port uses autoreconf, which is part of automake. Unfortunately, automake needs access to /tmp/ during configure, which doesn't exist. I guess I'll just have to edit the configure file on my PC and point it to a path that's accessible.
Does anyone know of an automake binary for Android?

Related

Questions about cross compiling

Has anyone been able to really utilize the tool chain that comes with the android source. I'm wanting to play with cross compiling for android some. I found a wrapper someone wrote in perl, but I've only had limited success using it. For more complex things that use build systems I've not been able to get anything to compile.
Would it just be easier to use another toolchain with something like uclibc?
What do JF and some others use to build stuff like busybox?

C Code in G1? JF? Anyone?

I'm just wondering is anyone trying this yet? i mean is it even possible?
Just a thought for you big shot android devs out there JF, Haykuro, LucidREM
Google "android jni"
Well, a quick trip around google would have helped you.
Android is using java, and currently it's not possible to use anything else.
But anyway, would you rather compile all of your code for multiple architectures? J makes things easier here...
You can write cli-apps in C though... i heard something about that there was plans to make other languages available in android, but i wouldn't hold my breath
Also, why is this related to JF/Haykuro/LucidREM?
I think you can do this with JNI: http://en.wikipedia.org/wiki/Java_Native_Interface
Using an ARM native compiler (such as the ones at CodeSourcery, http://www.codesourcery.com/sgpp/lite/arm/portal/[email protected]=lite) you can compile your apps and run them fine on the G1
Code:
$ arm-none-linux-gnueabi-gcc -static foo.c -o foo
$ adb push foo /data/foo # we are pushing to /data as it is +rwx (read, write, execute) for a standard user.
$ adb shell /data/foo
a=1
b=2
foo=a+b
foo=3
^^^
OH I love when I stumble across a post like this and have something new to play with.
The problem is due to the different location of the linker and mainly the different libc you have to statically link everything.
I have been having a hell of a time getting DPKG to build statically.
I picked up a copy of the newly released book, Unlocking Android, at Barnes and Noble yesterday. There is a whole chapter devoted to writing native apps using C (and ARM assembler) with the CodeSourcery tools linked above. The author walks through the steps you need to do to dynamically link the libraries so you don't end up with enormous statically linked executables. Well worth the price.
It is surprising what you can do with C on the phone, its actually not too difficult. The method outlined below doesn't use the non native toolchains and if you use the sourcery toolchain (as mentioned above) you will end up with bigger binaries as you need to link in a standard glibc and not androids bionic libc. This may or may not be important for your project.
The other advantage of the steps below is that you will build and link against any library that is available to the android platform
The easiest way that I've found to start when porting or writing new applications is this method.
1) Check out the current git android source.
2) Build the entire tree, "make" in the top level directory.
3) Create a new directory in mydroid/external/packagename/
4) Copy one of the simple android Android.mk (Make) files from a "like" target.
(If doing a library, choose a library, if coding an executable , choose that).
5) source the mydroid/build/envsetup.sh in the users bashrc
6) cd to your directory, then instead of the usual "make" do an mm.
This should create a binary, which you can adb push to the phone and run at the console.
You can do all the usual things if linked properly, like write the framebuffer using sdl, play sounds, create network connections.
Just remember that you dont have a standard libc (glibc) to play around with you have "bionic". If you are missing your favourite glibc function , it is probably intention and not abug. You'll either need to port it or make do with the functions provided by bionic.
These instructions are for a "pure" C program. you can mix the java like dex calling by 'shelling' out to the C application when you need performance, however premature optimization is the root of all evil, you'll be surprised what performance you can pull from davlik (And I expect the VM guys to improve this even further).
I know that is a lot to digest. Will do the best I can to answer your questions. I'm by no means an expert in the area, but have learned a bit about C on android.
Well I don't know much about all this but what i know is that e.g.
ScummVM IS written in C++ , and so is g-arcade.
His FAQ says:
"How did you do this? Is it Java?
No. ScummVM is a C++ program. For this port, I turned it into a really big JNI library so Android still thinks it's running a Java program, but almost all of it is implemented in C++."
(http://sites.google.com/site/scummvmandroid/faq#TOC-How-did-you-do-this-Is-it-Java-)
So if some1 wanna port MAME, feel free to xD

crazy request - C language compiler in browser?

If this doesn't exist, just tell me but I'd figure this was the best place to ask...
I'm looking for something like a C compiler for Android (please note I mean a C Compiler running ON android, not to compile FOR android). If there's a website that will run on android and will run C code like for learning purposes that would be great too.
Basically I'm learning C by reading on the train, and would love to be able to try my examples rather than just reading them. Appreciate any advice you might have. Worst case I just buy a netbook.
http://www.dignus.com/dcxx/compileit.html
I found this but it only outputs assembly language, which doesn't really tell me if my code is doing what I was hoping for. anything else along these lines?
Thanks again
There's a few websites that let you paste code and compile and run it. One such site is www.codepad.org. They're running in some virtual machine type environment for security purposes.
Another option would be to use something like ConnectBot to ssh to a computer somewhere and run gcc there.
On my Palm I fiddled a bit with OnBoard C. Would be great to get that one ported to Android.
http://onboardc.sourceforge.net/
Or an onboard version of Java for that matter.
[email protected] said:
There's a few websites that let you paste code and compile and run it. One such site is www.codepad.org. They're running in some virtual machine type environment for security purposes.
Another option would be to use something like ConnectBot to ssh to a computer somewhere and run gcc there.
Click to expand...
Click to collapse
Yeah I've considered the remote option, I can always do that. I guess I'm not really going to get a good experience no matter what when I'm on a tiny phone screen without a keyboard, right?
I really do appreciate that site though, that will be nice for playing around at work with.
christine600 said:
On my Palm I fiddled a bit with OnBoard C. Would be great to get that one ported to Android.
http://onboardc.sourceforge.net/
Or an onboard version of Java for that matter.
Click to expand...
Click to collapse
That looks sweet
Hi !
As far as I know, the Palm Pascal Compiler designer (PP and also PIAF and BIRD used by some onboardC users) is coding an onboard compiler for Android. It generates ARM executable code directly.
At this time, the application is not fully functionnal, but it nicely compiles some pieces of ISO Pascal code. It will also include an assembler (the disassembler is working well).
Once functionnal, I think it would be easy to create a C compiler (as it has been done with IZBasic)
Probably a bit late but for any others looking for something similar
berardi said:
If this doesn't exist, just tell me but I'd figure this was the best place to ask...
I'm looking for something like a C compiler for Android (please note I mean a C Compiler running ON android, not to compile FOR android). If there's a website that will run on android and will run C code like for learning purposes that would be great too.
Basically I'm learning C by reading on the train, and would love to be able to try my examples rather than just reading them. Appreciate any advice you might have. Worst case I just buy a netbook.
Click to expand...
Click to collapse
I just found this, it may not be 100% free but give it a look eitherway
https://compilr.com

Compile and execute programs on Android 2.2

Hello friends,
I am in need of an installation of gcc such that I can execute the gcc command in the terminal emulator.
My aim is to be successful in writing and compiling programs on my Android (LG Optimus One P500) during travelling and other wasted time.
Thanks.
Probably not exactly what you want but here's the closest I've got for you, http://code.google.com/p/android-scripting/
I'm looking at the same thing on my debian machine and from what i gather the android sdk devel tools along with nvidia's tegra addon give you an arm cross compiler and the include files and kernel headers you'd need.
d0ugie said:
Probably not exactly what you want but here's the closest I've got for you, LINK
Click to expand...
Click to collapse
Thanks for the link. I am trying them out tonight.
gitorious.org/android-toolchain > Someone please try this out and tell me if it works (I will try it out by myself this weekend anyway... So if you have time )
touchqode - mobile code editor and SL4A
I'm not sure if I can post links, but you can search the Internet and/or market to find it. I've played with it for a minute, but plan to use it along with SL4A since they both support Javascript. I don't think Sl4A supports PHP at the moment, but I'm pretty sure it'll be added at some point. I hope this helps.
Topcheese said:
I'm not sure if I can post links, but you can search the Internet and/or market to find it. I've played with it for a minute, but plan to use it along with SL4A since they both support Javascript. I don't think Sl4A supports PHP at the moment, but I'm pretty sure it'll be added at some point. I hope this helps.
Click to expand...
Click to collapse
I am quite satisfied with the range of languages I have. Python + Lua + Perl
My goal was to make g++ and gcc run on Android, but I think I am done for now. Next would be making Debian work for my LG

Custom clib, a bionic/eglibc hybrid, thoughts ?

I am fairly new to the game so this might have been solved before or maybe a project somewhere is already working on it, but I'll ask anyways...
I want to build a version of Android that runs on glibc but also has the Android specific libs to run it's framework, system services, dalvik, etc...
So I have the source for both as well as the sources for gcc 4.8.2, I am thinking I need to eleminate from bionic what exists in the gnu side of things, and then add what is left in bionic and doesn't exist in eglibc or the stdc++ library in gcc to that, or maybe the other way around. And then write an Android.mk file to build it with Cyanogenmod-10.3 in place of bionic.
Thats my game plan and I am sure there are some holes in it, maybe I need to modify the NDK as well, and I am sure I need to change some includes through-out the Android sources, or maybe write some headers that wrap around the eglibc version of the functions, methods, classes, etc.. that are named differently but are basically the same function.
Mabye someone with a bit more experience in the field can shed some light on what they think about the above.
Any guidance, references, quotes, links, articles, insight, or advice?

Categories

Resources