I got the hello_world.c file to compile and run.
In short I installed Binutils (for ld and as) and some libraries (.a and
.so files) from the Android NDK to get it compile. Binutils I compiled
myself but the libraries I just ripped from Android NDK hoping they would
just work (which they did). It's also worth noting that right now the
--save-temps and --sysroot are necessary becuase of the way everything is
setup. I think I might be able to get it to work without those flags and
more importantly I think emscripten might have problems with it if I don't.
I probably could've taken the ld and as from the NDK but I didn't think
they were compiled for use on arm so I just grabbed NDK toolchain sources
and built binutils-2.21 with NDK. I needed to make some changes to get it
to compile which I included them in the diff attached to this post. I also
needed to build and install texinfo to the NDK toolchain (binutils wouldn't
complain about missing makeinfo) which thankfully was straightforward as no
patches or other dependencies were needed.
So if I had to repeat the process again I would just do.
#retrieve the files
git clone https://android.googlesource.com/toolchain/binutils
wget http://ftp.gnu.org/gnu/texinfo/texinfo-5.2.tar.gz
tar -zxvf texinfo-5.2.tar.gz
#set the environment variables
export PLATFORM_PREFIX=/home/bobajeff/android-ext
export NDK_PATH=/home/bobajeff/Downloads/android-ndk-r10
export NDK_PLATFORM=android-9
export PATH=$PLATFORM_PREFIX/bin:$PATH
#build and install texinfo to NDK toolchain
cd texinfo-5.2
mkdir build
cd build
../configure --host=arm-linux-androideabi --prefix=$PLATFORM_PREFIX
make
make install
#build binutils
cd ../../binutils/binutils-2.21
#assuming the patch file is in the same location you cloned binutils
patch -p1 < ../../binutils-2.21_sloppyquick_android_compat.diff
mkdir build
cd build
../configure --host=arm-linux-androideabi --prefix=$PLATFORM_PREFIX --with-
sysroot
make
#Note: I'd already deleted the fastcomp files that were in clangandroid
previously
make DESTDIR=/home/bobajeff/clangandroid install
Then assuming everything went well you push binutils along with the
necessary libraries to android terminal emulator:
#push binutils.
adt-bundle-linux-x86-20140702/sdk/platform-tools/adb push /home/bobajeff/
clangandroid/home/bobajeff/android-ext /data/data/jackpal.androidterm/
shared_prefs
#push the libraries
adt-bundle-linux-x86-20140702/sdk/platform-tools/adb push /home/bobajeff/
android-ext/sysroot/usr/lib /data/data/jackpal.androidterm/shared_prefs/lib
adt-bundle-linux-x86-20140702/sdk/platform-tools/adb push /home/bobajeff/
android-ext/lib/gcc/arm-linux-androideabi/4.6/armv7-a/libgcc.a /data/data/
jackpal.androidterm/shared_prefs/lib
If all goes well you should be able to compile from inside android terminal
emulator by doing.
cd /data/data/jackpal.androidterm/shared_prefs/
bin/clang --save-temps hello_world.c -isystem/data/data/jackpal.androidterm/
shared_prefs/include/libc --sysroot=/data/data/jackpal.androidterm/
shared_prefs/
On Thursday, July 17, 2014 7:47:42 AM UTC-5, [email protected] wrote:
>
> I fascinated with the idea of using Android code editor/IDE (like
> DroidEdit or AIDE) to program C++ applications while on a phone.
>
> I was wondering if there is a way to run emscripten on Android. Can I
> compile emscripten to android? Has anyone tried it?
>
>
>
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff -Naur binutils-2.21/bfd/archive.c binutils-2.21b/bfd/archive.c
--- binutils-2.21/bfd/archive.c 2014-08-24 18:51:53.388376000 -0500
+++ binutils-2.21b/bfd/archive.c 2014-08-24 15:45:45.324279000 -0500
@@ -1755,7 +1755,7 @@
{
/* Assume we just "made" the member, and fake it. */
struct bfd_in_memory *bim = (struct bfd_in_memory *) member->iostream;
- time (&status.st_mtime);
+ time ((time_t *)&status.st_mtime);
status.st_uid = getuid ();
status.st_gid = getgid ();
status.st_mode = 0644;
diff -Naur binutils-2.21/ld/plugin.c binutils-2.21b/ld/plugin.c
--- binutils-2.21/ld/plugin.c 2014-08-24 18:51:57.160457000 -0500
+++ binutils-2.21b/ld/plugin.c 2014-08-24 16:19:36.797096000 -0500
@@ -580,8 +580,8 @@
size_t i;
/* Version info. */
- static const unsigned int major = (unsigned)(BFD_VERSION / 100000000UL);
- static const unsigned int minor = (unsigned)(BFD_VERSION / 1000000UL) % 100;
+ static const unsigned int major_ver = (unsigned)(BFD_VERSION / 100000000UL);
+ static const unsigned int minor_ver = (unsigned)(BFD_VERSION / 1000000UL) % 100;
if (!tv)
return tv_header_size;
@@ -599,7 +599,7 @@
TVU(val) = LD_PLUGIN_API_VERSION;
break;
case LDPT_GNU_LD_VERSION:
- TVU(val) = major * 100 + minor;
+ TVU(val) = major_ver * 100 + minor_ver;
break;
case LDPT_LINKER_OUTPUT:
TVU(val) = link_info.relocatable ? LDPO_REL
diff -Naur binutils-2.21/libiberty/getpagesize.c binutils-2.21b/libiberty/getpagesize.c
--- binutils-2.21/libiberty/getpagesize.c 2014-08-24 18:51:58.056476000 -0500
+++ binutils-2.21b/libiberty/getpagesize.c 2014-08-24 14:21:38.965414000 -0500
@@ -59,13 +59,13 @@
# endif /* EXEC_PAGESIZE */
# endif /* PAGESIZE */
#endif /* GNU_OUR_PAGESIZE */
-
+#ifndef __ANDROID__
int
getpagesize (void)
{
return (GNU_OUR_PAGESIZE);
}
-
+#endif
#else /* VMS */
#if 0 /* older distributions of gcc-vms are missing <syidef.h> */