Git Product home page Git Product logo

opam-cross-android's Introduction

opam-cross-android

This repository contains an up-to-date Android toolchain featuring OCaml 4.04.0, as well as some commonly used packages.

The supported build systems are 32-bit and 64-bit x86 Linux. The supported target systems are 32-bit x86 and ARM Android.

If you need support for other platforms or versions, please open an issue.

Prerequisites

On 64-bit Linux build systems, 32-bit libraries must be installed. On Debian derivatives they are provided in the gcc-multilib package.

The compiled toolchain requires about 5G of disk space.

Installation

Add this repository to OPAM:

opam repository add android git://github.com/whitequark/opam-cross-android

On 64-bit build systems, switch to 32-bit compiler when compiling for 32-bit targets:

opam switch 4.04.0+32bit
eval `opam config env`

Otherwise, use a regular compiler; its version must match the version of the cross-compiler:

opam switch 4.04.0
eval `opam config env`

Pin some prerequisite packages that don't yet have fixes merged upstream:

opam pin add ocamlbuild https://github.com/ocaml/ocamlbuild.git
opam pin add topkg https://github.com/whitequark/topkg.git

Configure the compiler for ARM:

ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi \
  CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 \
  TRIPLE=arm-linux-androideabi LEVEL=24 \
  STLVER=4.9 STLARCH=armeabi \
  opam install conf-android

Alternatively, configure the compiler for AArch64:

ARCH=arm64 SUBARCH=arm64 SYSTEM=linux_eabi \
  CCARCH=arm64 TOOLCHAIN=aarch64-linux-android-4.9 \
  TRIPLE=aarch64-linux-android LEVEL=24 \
  STLVER=4.9 STLARCH=arm64-v8a \
  opam install conf-android

Alternatively, configure the compiler for x86:

ARCH=i386 SUBARCH=default SYSTEM=linux_elf \
  CCARCH=x86 TOOLCHAIN=x86-4.9 \
  TRIPLE=i686-linux-android LEVEL=24 \
  STLVER=4.9 STLARCH=x86 \
  opam install conf-android

Some options can be tweaked:

  • SUBARCH (on ARM) specifies the ARM architecture version, e.g. armv5te or armv7;
  • SYSTEM (on ARM) specifies the ABI: linux_eabi for soft-float and linux_eabihf for hard-float;
  • LEVEL specifies the Android API level and defaults to latest available API.

The options above (ARCH, SUBARCH, SYSTEM, LEVEL, TOOLCHAIN and TRIPLE) are recorded inside the conf-android package, so make sure to reinstall that package if you wish to switch to a different toolchain. Otherwise, it is not necessary to supply them while upgrading the ocaml-android* packages.

If desired, request the compiler to be built with flambda optimizers:

opam install conf-flambda-android

Install the compiler:

opam install ocaml-android

Build some code:

echo 'let () = print_endline "Hello, world!"' >helloworld.ml
ocamlfind -toolchain android ocamlc -custom helloworld.ml -o helloworld.byte
ocamlfind -toolchain android ocamlopt helloworld.ml -o helloworld.native

Install some packages:

opam install re-android

Write some code using them:

let () =
  let regexp = Re_pcre.regexp {|\b([a-z]+)\b|} in
  let result = Re.exec regexp "Hello, world!" in
  Format.printf "match: %s\n" (Re.get result 1)

Build it:

ocamlfind -toolchain android ocamlopt -package re.pcre -linkpkg test_pcre.ml -o test_pcre

Make an object file out of it and link it with your Android project (you'll need to call caml_startup(argv) to run OCaml code; see this article):

ocamlfind -toolchain android ocamlopt -package re.pcre -linkpkg -output-complete-obj test_pcre.ml -o test_pcre.o

Make a shared object out of it:

ocamlfind -toolchain android ocamlopt -package re.pcre -linkpkg -output-obj -cclib -shared test_pcre.ml -o test_pcre.so

With opam-android, cross-compilation is easy!

Porting packages

OCaml packages often have components that execute at compile-time (camlp4 or ppx syntax extensions, cstubs, OASIS, ...). Thus, it is not possible to just blanketly cross-compile every package in the OPAM repository; sometimes you would even need a cross-compiled and a non-cross-compiled package at once. The package definitions also often need package-specific modification in order to work.

As a result, if you want a package to be cross-compiled, you have to copy the definition from opam-repository, rename the package to add -android suffix while updating any dependencies it could have, and update the build script. Don't forget to add ocaml-android as a dependency!

Findlib 1.5.4 adds a feature that makes porting packages much simpler; namely, an OCAMLFIND_TOOLCHAIN environment variable that is equivalent to the -toolchain command-line flag. Now it is not necessary to patch the build systems of the packages to select the Android toolchain; it is often enough to add ["env" "OCAMLFIND_TOOLCHAIN=android" make ...] to the build command in the opam file.

For projects using OASIS, the following steps will work:

build: [
  ["ocaml" "setup.ml" "-configure" "--prefix" "%{prefix}%/android-sysroot"]
  ["env" "OCAMLFIND_TOOLCHAIN=android" "ocaml" "setup.ml" "-build"]
]
install: [
  ["env" "OCAMLFIND_TOOLCHAIN=android" "ocaml" "setup.ml" "-install"]
]
remove: [["ocamlfind" "-toolchain" "android" "remove" "pkg"]]
depends: ["ocaml-android" ...]

The output of the configure script will be entirely wrong, referring to the host configuration rather than target configuration. Thankfully, it is not actually used in the build process itself, so it doesn't matter.

For projects installing the files via OPAM's .install files (e.g. topkg), the following steps will work:

build: [["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "--toolchain" "windows" ]]
install: [["opam-installer" "--prefix=%{prefix}%/android-sysroot" "pkg.install"]]
remove: [["ocamlfind" "-toolchain" "android" "remove" "pkg"]]
depends: ["ocaml-android" ...]

Internals

The aim of this repository is to build a cross-compiler while altering the original codebase in the minimal possible way. (Indeed, only about 50 lines are changed.) There are no attempts to alter the configure script; rather, the configuration is provided directly. The resulting cross-compiler has several interesting properties:

  • All paths to the Android toolchain are embedded inside ocamlc and ocamlopt; thus, no knowledge of the Android toolchain is required even for packages that have components in C, provided they use the OCaml driver to compile the C code. (This is usually the case.)
  • The build system makes several assumptions that are not strictly valid while cross-compiling, mainly the fact that the bytecode the cross-compiler has just built can be ran by the ocamlrun on the build system. Thus, the requirement for a 32-bit build compiler for 32-bit targets, as well as for the matching versions.
  • The .opt versions of the compiler are built using itself, which doesn't work while cross-compiling, so all provided tools are bytecode-based.

License

All files contained in this repository are licensed under the CC0 1.0 Universal license.

Acknowledgements

Some of the tricks in this repository were inspired by Jerome Vouillon's opam-android-repository. However, no code was reused.

References

See also opam-cross-windows and opam-cross-ios.

opam-cross-android's People

Contributors

dbuenzli avatar hnrgrgr avatar julow avatar thomas-huet avatar whitequark avatar yallop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opam-cross-android's Issues

creating ppx_deriving_protobuf-android.2.5

For my previous cross-compiler suite I simply changed your pkg/build.ml:

...
let ocamlbuild =
  "ocamlbuild -use-ocamlfind -ocamlc '-toolchain arm ocamlc' -ocamldep '-toolchain arm ocamldep' -ocamlopt '-toolchain arm ocamlopt' -classic-display -plugin-tag 'package(cppo_ocamlbuild)'"
...

For new version I tried to follow your instructions for topkg based packages in README.md, but pkg/build.ml doesn't understand "--toolchain android" arguments, so I changed opam file:

build: [
  "env" "OCAMLFIND_TOOLCHAIN=android" "ocaml" "pkg/build.ml" "native=%{ocaml-native}%"
                         "native-dynlink=%{ocaml-native-dynlink}%"
]

But it does not enough to cross-compile package:

[ppx_deriving_protobuf-android: env ocaml] Command started
+ env "OCAMLFIND_TOOLCHAIN=android" "ocaml" "pkg/build.ml" "native=true" "native-dynlink=true" (CWD=/home/ssp/.opam/4.04.0+32bit/build/ppx_deriving_protobuf-android.2.5)
- ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package cppo_ocamlbuild myocamlbuild.ml /home/ssp/.opam/4.04.0+32bit/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
- + ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package cppo_ocamlbuild myocamlbuild.ml /home/ssp/.opam/4.04.0+32bit/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
- ocamlfind: Package `ocamlbuild' not found
- Command exited with code 2.

How you will recomend to prepare this package to cross-compilation?
Should I add remove section to opam file too?

x86 install fails with "unknown argument '-Qunused-arguments'"

Following the readme, on 4.04.0+32bit, I get this error. On macos 10.12.6

#=== ERROR while installing ocaml-android32.4.04.0 ============================#
# opam-version 1.2.2
# os           darwin
# command      make world opt install
# path         /Users/jared/.opam/4.04.0+32bit/build/ocaml-android32.4.04.0
# compiler     4.04.0+32bit
# exit-code    2
# env-file     /Users/jared/.opam/4.04.0+32bit/build/ocaml-android32.4.04.0/ocaml-android32-26709-2dea01.env
# stdout-file  /Users/jared/.opam/4.04.0+32bit/build/ocaml-android32.4.04.0/ocaml-android32-26709-2dea01.out
# stderr-file  /Users/jared/.opam/4.04.0+32bit/build/ocaml-android32.4.04.0/ocaml-android32-26709-2dea01.err
### stdout ###
# /Applications/Xcode.app/Contents/Developer/usr/bin/make coldstart
# cd byterun; /Applications/Xcode.app/Contents/Developer/usr/bin/make all
# sed -n -e '/^  /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \
#              -e '/^}/q' caml/instruct.h > caml/jumptbl.h
# /Users/jared/.opam/4.04.0+32bit/android-ndk/toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-gcc --sysroot /Users/jared/.opam/4.04.0+32bit/android-ndk/platforms/android-24/arch-x86 -I/Users/jared/.opam/4.04.0+32bit/android-ndk/include -L/Users/jared/.opam/4.04.0+32bit/android-ndk/lib -I/Users/jared/.opam/4.04.0+32bit/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -I/Users/jared/.opam/4.04.0+32bit/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -L/Users/jared/.opam/4.04.0+32bit/android-ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86 -I/Users/jared/.opam/4.04.0+32bit/android-sysroot/include -L/Users/jared/.opam/4.04.0+32bit/android-sysroot/lib -O2 -DCAML_NAME_SPACE -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT  -Qunused-arguments  -c -o interp.o interp.c
### stderr ###
# i686-linux-android-gcc: error: unrecognized command line option '-Qunused-arguments'

tgls-android fails to compile

opam install nanovg-android
The following actions will be performed:
  ∗  install tgls-android   dev               [required by nanovg-android]
       tgls-android only includes support for GLES2
  ∗  install nanovg-android dev
===== ∗  2 =====
Do you want to continue ? [Y/n] y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
[nanovg-android] git://github.com/caseybasichis/nanoVG already up-to-date
[tgls-android] git://github.com/whitequark/tgls#stubs-0.4 already up-to-date

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
[ERROR] The compilation of tgls-android failed at "ocamlbuild -use-ocamlfind
        support/bindgen.byte".
Processing  1/2: [tgls-android: ocamlfind android]
#=== ERROR while installing tgls-android.dev ==================================#
# opam-version 1.2.2
# os           darwin
# command      ocamlbuild -use-ocamlfind support/bindgen.byte
# path         /Users/joelr/.opam/4.02.3+32bit/build/tgls-android.dev
# compiler     4.02.3+32bit
# exit-code    10
# env-file     /Users/joelr/.opam/4.02.3+32bit/build/tgls-android.dev/tgls-android-59258-d2d111.env
# stdout-file  /Users/joelr/.opam/4.02.3+32bit/build/tgls-android.dev/tgls-android-59258-d2d111.out
# stderr-file  /Users/joelr/.opam/4.02.3+32bit/build/tgls-android.dev/tgls-android-59258-d2d111.err
### stdout ###
# [...]
# Error: This expression has type
#          (bitfield ->
#           (int ->
#            (unit Ctypes_static.ptr ->
#             (bitfield -> unit Foreign.return Foreign.fn) Foreign.fn)
#            Foreign.fn)
#           Foreign.fn)
#          Foreign.result
#        This is not a function; it cannot be applied.
# Command exited with code 2.

tgls-android fails to compile

opam install tgls-android
The following actions will be performed:
  ∗  install tgls-android dev
       tgls-android only includes support for GLES2

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
[tgls-android] git://github.com/whitequark/tgls#stubs-0.4 already up-to-date

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
[ERROR] The compilation of tgls-android failed at "ocamlbuild -use-ocamlfind
        support/bindgen.byte".
Processing  1/1: [tgls-android: ocamlfind android]
#=== ERROR while installing tgls-android.dev ==================================#
# opam-version 1.2.2
# os           darwin
# command      ocamlbuild -use-ocamlfind support/bindgen.byte
# path         /Users/joelr/.opam/4.02.3+32bit/build/tgls-android.dev
# compiler     4.02.3+32bit
# exit-code    10
# env-file     /Users/joelr/.opam/4.02.3+32bit/build/tgls-android.dev/tgls-android-59487-d2c37b.env
# stdout-file  /Users/joelr/.opam/4.02.3+32bit/build/tgls-android.dev/tgls-android-59487-d2c37b.out
# stderr-file  /Users/joelr/.opam/4.02.3+32bit/build/tgls-android.dev/tgls-android-59487-d2c37b.err
### stdout ###
# [...]
# Error: This expression has type
#          (bitfield ->
#           (int ->
#            (unit Ctypes_static.ptr ->
#             (bitfield -> unit Foreign.return Foreign.fn) Foreign.fn)
#            Foreign.fn)
#           Foreign.fn)
#          Foreign.result
#        This is not a function; it cannot be applied.
# Command exited with code 2.

opam upgrade problem

I've been successfully using 4.02.1 version of opal-android. I'm trying to upgrade my 32-bit opam-android installation and running into a problem. I'm building on a debian 64-bit install. The host compiler is 4.02.1 32-bit, but opal-android seems to now require 4.02.2 32-bit. I don't see a matching compiler listed by 'opam switch'. Is there a trick to getting this to work? The instructions seem out of date in that the refer to ocaml version 4.02.1. Are there plans to upgrade to current 4.02.3 compiler?

thanks, Mark

debian64% opam upgrade
Everything as up-to-date as possible (run with --verbose to show unavailable
upgrades).
The following would require downgrades or uninstalls, but you may upgrade
them explicitly:
  - ocaml-android.4.02.2
debian64% opam install ocaml-android.4.02.2
The following dependencies couldn't be met:
  - ocaml-android -> ocaml-android32 = 4.02.2
Your request can't be satisfied:
  - ocaml-android32.4.02.2 is not available because your system doesn't comply with ocaml-version = "4.02.2" & arch = "x86" | compiler = "4.02.2+32bit".

No solution found, exiting
debian64% opam switch
--           -- 3.11.2        Official 3.11.2 release
--           -- 3.12.1        Official 3.12.1 release
--           -- 4.00.0        Official 4.00.0 release
--           -- 4.00.1        Official 4.00.1 release
--           -- 4.01.0        Official 4.01.0 release
--           -- 4.02.0        Official 4.02.0 release
4.02.1+32bit  C 4.02.1+32bit  4.02.1 compiled in 32-bit mode for 64-bit Linux and OS X hosts.
4.02.1        I 4.02.1        Official 4.02.1 release
--           -- 4.02.2        Official 4.02.2 release
--           -- 4.02.3        Official 4.02.3 release
system        I system        System compiler (4.00.0)
#102 more patched or experimental compilers, use '--all' to show


debian64% 

problem building yojson-android

  • opam switch 4.02.3+32bit

    To setup the new switch in the current shell, you need to run:

    eval opam config env
  • false
  • opam='env ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 TRIPLE=arm-linux-androideabi LEVEL=15 opam'
  • env ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 TRIPLE=arm-linux-androideabi LEVEL=15 opam update

=-=- Updating package repositories =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[android] git://github.com/whitequark/opam-cross-android already up-to-date
[windows] git://github.com/whitequark/opam-cross-windows already up-to-date
[default] synchronized from https://opam.ocaml.org

  • env ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 TRIPLE=arm-linux-androideabi LEVEL=15 opam upgrade
    Everything as up-to-date as possible (run with --verbose to show unavailable upgrades).
  • env ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 TRIPLE=arm-linux-androideabi LEVEL=15 opam install ocaml-android yojson-android biniou-android easy-format-android
    [NOTE] Package ocaml-android is already installed (current version is 4.02.3).
    [NOTE] Package biniou-android is already installed (current version is 1.0.10).
    [NOTE] Package easy-format-android is already installed (current version is 1.2.0).
    The following actions will be performed:
    • install yojson-android 1.3.2
      Do you want to continue ? [Y/n] y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[yojson-android.1.3.2] https://github.com/mjambon/yojson/archive/v1.2.0.tar.gz downloaded

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] Patch file "/home/mhayden/.opam/4.02.3+32bit/build/yojson-android.1.3.2/patches/cross-compiling.diff" not found.

=== ERROR while installing yojson-android.1.3.2 ==============================

These patches didn't apply at /home/mhayden/.opam/4.02.3+32bit/build/yojson-android.1.3.2:

  • patches/cross-compiling.diff

=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions failed

  • install yojson-android 1.3.2
    No changes have been performed
    debian64%

ppx_deriving-android.4.1 creates native library (as for x86 as for x64) instead of ARM version

When I tried to build my code I got:

ssp@ssp-vb:/mnt/ssp/1$ ocamlbuild -toolchain android -use-ocamlfind router.native
+ ocamlfind -toolchain android ocamlc -c -package ZMQ -package lwt.unix -package ppx_deriving_protobuf -o router.cmo router.ml
+ ocamlfind -toolchain android ocamlopt -c -package ZMQ -package lwt.unix -package ppx_deriving_protobuf -o router.cmx router.ml
+ ocamlfind -toolchain android ocamlopt -linkpkg -package ZMQ -package lwt.unix -package ppx_deriving_protobuf lwt_zmq.cmx router.cmx -o router.native
/home/ssp/build/tmp-glibc/sysroots/i686-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/6.2.0/ld: warning: library search path "/usr/local/lib" is unsafe for cross-compilation
/home/ssp/build/tmp-glibc/sysroots/i686-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/6.2.0/ld: /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ppx_deriving/ppx_deriving_runtime.a(ppx_deriving_runtime.o): Relocations in generic ELF (EM: 3)
/home/ssp/build/tmp-glibc/sysroots/i686-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/6.2.0/ld: /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ppx_deriving/ppx_deriving_runtime.a(ppx_deriving_runtime.o): Relocations in generic ELF (EM: 3)
/home/ssp/build/tmp-glibc/sysroots/i686-linux/usr/libexec/arm-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/6.2.0/ld: /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ppx_deriving/ppx_deriving_runtime.a(ppx_deriving_runtime.o): Relocations in generic ELF (EM: 3)
/home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ppx_deriving/ppx_deriving_runtime.a: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking
Command exited with code 2.
Compilation unsuccessful after building 7 targets (0 cached) in 00:00:01.

So, I've extracted content of ppx_deriving_runtime.a:

ssp@ssp-vb:/mnt/ssp/1$ ar x /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ppx_deriving/ppx_deriving_runtime.a
ssp@ssp-vb:/mnt/ssp/1$ file ppx_deriving_runtime.o 
ppx_deriving_runtime.o: ELF 32-bit LSB  relocatable, Intel 80386, version 1 (SYSV), not stripped

It's simple to fix ppx_deriving-android to create right version of library: just add "-toolchain android" to pkg/build.ml:

let ocamlbuild =
  "ocamlbuild -toolchain android -use-ocamlfind -classic-display -plugin-tag " ^ quote_parens "package(cppo_ocamlbuild)"

But package failed to build since it can't find dynlink.cmxa compiled for ARM:

sp@ssp-vb:/mnt/ssp/4.04/ppx_deriving-android.4.1$ make
cp pkg/META.in pkg/META
ocaml pkg/build.ml native=true native-dynlink=true
ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package cppo_ocamlbuild myocamlbuild.ml /home/ssp/.opam/4.04.0+32bit/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
cppo -V OCAML:4.04.0 -o src/ppx_deriving_main.ml src/ppx_deriving_main.cppo.ml
ocamlfind -toolchain android ocamldep -package compiler-libs.common -package ppx_tools.metaquot -package findlib.dynload -predicates ppx_driver -package dynlink -package result -modules src/ppx_deriving_main.ml > src/ppx_deriving_main.ml.depends
ocamlfind -toolchain android ocamldep -package compiler-libs.common -package ppx_tools.metaquot -package dynlink -package result -modules src/ppx_deriving.mli > src/ppx_deriving.mli.depends
ocamlfind -toolchain android ocamlc -c -g -bin-annot -safe-string -package compiler-libs.common -package ppx_tools.metaquot -package dynlink -package result -w @5@8@10@11@12@14@23@24@26@29@40 -I src -o src/ppx_deriving.cmi src/ppx_deriving.mli
+ ocamlfind -toolchain android ocamlc -c -g -bin-annot -safe-string -package compiler-libs.common -package ppx_tools.metaquot -package dynlink -package result -w @5@8@10@11@12@14@23@24@26@29@40 -I src -o src/ppx_deriving.cmi src/ppx_deriving.mli
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml, /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml/compiler-libs
ocamlfind -toolchain android ocamlc -c -g -bin-annot -safe-string -package compiler-libs.common -package ppx_tools.metaquot -package findlib.dynload -predicates ppx_driver -package dynlink -package result -w @5@8@10@11@12@14@23@24@26@29@40 -I src -o src/ppx_deriving_main.cmo src/ppx_deriving_main.ml
+ ocamlfind -toolchain android ocamlc -c -g -bin-annot -safe-string -package compiler-libs.common -package ppx_tools.metaquot -package findlib.dynload -predicates ppx_driver -package dynlink -package result -w @5@8@10@11@12@14@23@24@26@29@40 -I src -o src/ppx_deriving_main.cmo src/ppx_deriving_main.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml, /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml/compiler-libs
cppo -V OCAML:4.04.0 -o src/ppx_deriving.ml src/ppx_deriving.cppo.ml
ocamlfind -toolchain android ocamldep -package compiler-libs.common -package ppx_tools.metaquot -package dynlink -package result -modules src/ppx_deriving.ml > src/ppx_deriving.ml.depends
ocamlfind -toolchain android ocamlopt -c -g -bin-annot -safe-string -package compiler-libs.common -package ppx_tools.metaquot -package dynlink -package result -w @5@8@10@11@12@14@23@24@26@29@40 -I src -o src/ppx_deriving.cmx src/ppx_deriving.ml
+ ocamlfind -toolchain android ocamlopt -c -g -bin-annot -safe-string -package compiler-libs.common -package ppx_tools.metaquot -package dynlink -package result -w @5@8@10@11@12@14@23@24@26@29@40 -I src -o src/ppx_deriving.cmx src/ppx_deriving.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml, /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml/compiler-libs
File "src/ppx_deriving.cppo.ml", line 463, characters 17-34:
Warning 3: deprecated: String.capitalize
Use String.capitalize_ascii instead.
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Ast_helper, and its interface was not compiled with -opaque
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Ast_mapper, and its interface was not compiled with -opaque
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Location, and its interface was not compiled with -opaque
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Longident, and its interface was not compiled with -opaque
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Pprintast, and its interface was not compiled with -opaque
ocamlfind -toolchain android ocamlopt -c -g -bin-annot -safe-string -package compiler-libs.common -package ppx_tools.metaquot -package findlib.dynload -predicates ppx_driver -package dynlink -package result -w @5@8@10@11@12@14@23@24@26@29@40 -I src -o src/ppx_deriving_main.cmx src/ppx_deriving_main.ml
+ ocamlfind -toolchain android ocamlopt -c -g -bin-annot -safe-string -package compiler-libs.common -package ppx_tools.metaquot -package findlib.dynload -predicates ppx_driver -package dynlink -package result -w @5@8@10@11@12@14@23@24@26@29@40 -I src -o src/ppx_deriving_main.cmx src/ppx_deriving_main.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml, /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml/compiler-libs
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Ast_helper, and its interface was not compiled with -opaque
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Ast_mapper, and its interface was not compiled with -opaque
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Dynlink, and its interface was not compiled with -opaque
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Location, and its interface was not compiled with -opaque
ocamlfind -toolchain android ocamlopt -linkpkg -g -linkall -package compiler-libs.common -package ppx_tools.metaquot -package findlib.dynload -predicates ppx_driver -package dynlink -package result -I src src/ppx_deriving.cmx src/ppx_deriving_main.cmx -o src/ppx_deriving_main.native
+ ocamlfind -toolchain android ocamlopt -linkpkg -g -linkall -package compiler-libs.common -package ppx_tools.metaquot -package findlib.dynload -predicates ppx_driver -package dynlink -package result -I src src/ppx_deriving.cmx src/ppx_deriving_main.cmx -o src/ppx_deriving_main.native
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml, /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml/compiler-libs
File "/tmp/findlib_initlc51201.ml", line 1:
Error: Cannot find file /home/ssp/.opam/4.04.0+32bit/android-sysroot/lib/ocaml/dynlink.cmxa
Command exited with code 2.
make: *** [build] Error 10

some packages will not download

easy-format and biniou won't download. --M

  • env ANDROID_LEVEL=15 ANDROID_ABI=linux_eabi ANDROID_ARCH=armv7 opam install ocaml-android yojson-android biniou-android easy-format-android
    The following actions will be performed:
    • install android-ndk-linux 11c [required by conf-android]
    • install conf-android 1 [required by ocaml-android32]
    • install ocaml-android32 4.02.3 [required by ocaml-android]
    • install ocaml-android 4.02.3
    • install easy-format-android 1.2.0
    • install biniou-android 1.0.10
    • install yojson-android 1.3.2
      ===== 7 to install =====
      Do you want to continue ? [Y/n]
      y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] curl: code 404 while downloading
http://mjambon.com/releases/easy-format/easy-format-1.2.0.tar.gz
[ERROR] curl: code 404 while downloading
http://mjambon.com/releases/biniou/biniou-1.0.10.tar.gz
[yojson-android.1.3.2] https://github.com/mjambon/yojson/archive/v1.2.0.tar.gz downloaded

Extra '/' in ocaml native runtime library objects when hosted on MacOS

Also there is a strange '/' file included in the archive.

% ar t -Lv /Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib/ocaml/libasmrun.a
--------- 0/0 15490 Apr 22 12:25 2016 /
rw-rw-r-- 501/20 4508 Apr 22 12:24 2016 startup.o/
rw-rw-r-- 501/20 1008 Apr 22 12:24 2016 main.o/
rw-rw-r-- 501/20 4248 Apr 22 12:24 2016 fail.o/
rw-rw-r-- 501/20 5192 Apr 22 12:24 2016 roots.o/
rw-rw-r-- 501/20 5180 Apr 22 12:24 2016 globroots.o/
rw-rw-r-- 501/20 4612 Apr 22 12:24 2016 signals.o/
rw-rw-r-- 501/20 2024 Apr 22 12:24 2016 signals_asm.o/
rw-rw-r-- 501/20 2776 Apr 22 12:24 2016 misc.o/
rw-rw-r-- 501/20 5764 Apr 22 12:24 2016 freelist.o/
rw-rw-r-- 501/20 9204 Apr 22 12:24 2016 major_gc.o/
rw-rw-r-- 501/20 5904 Apr 22 12:24 2016 minor_gc.o/
rw-rw-r-- 501/20 6360 Apr 22 12:24 2016 memory.o/
rw-rw-r-- 501/20 3376 Apr 22 12:24 2016 alloc.o/
rw-rw-r-- 501/20 5436 Apr 22 12:24 2016 compare.o/
rw-rw-r-- 501/20 11948 Apr 22 12:24 2016 ints.o/
rw-rw-r-- 501/20 7784 Apr 22 12:24 2016 floats.o/
rw-rw-r-- 501/20 4112 Apr 22 12:24 2016 str.o/
rw-rw-r-- 501/20 6300 Apr 22 12:24 2016 array.o/
rw-rw-r-- 501/20 11756 Apr 22 12:24 2016 io.o/
rw-rw-r-- 501/20 12712 Apr 22 12:24 2016 extern.o/
rw-rw-r-- 501/20 13056 Apr 22 12:24 2016 intern.o/
rw-rw-r-- 501/20 4560 Apr 22 12:24 2016 hash.o/
rw-rw-r-- 501/20 7736 Apr 22 12:24 2016 sys.o/
rw-rw-r-- 501/20 4344 Apr 22 12:24 2016 parsing.o/
rw-rw-r-- 501/20 9836 Apr 22 12:24 2016 gc_ctrl.o/
rw-rw-r-- 501/20 1412 Apr 22 12:24 2016 terminfo.o/
rw-rw-r-- 501/20 5256 Apr 22 12:24 2016 md5.o/
rw-rw-r-- 501/20 3584 Apr 22 12:24 2016 obj.o/
rw-rw-r-- 501/20 1920 Apr 22 12:24 2016 lexing.o/
rw-rw-r-- 501/20 2844 Apr 22 12:24 2016 printexc.o/
rw-rw-r-- 501/20 2652 Apr 22 12:24 2016 callback.o/
rw-rw-r-- 501/20 4340 Apr 22 12:24 2016 weak.o/
rw-rw-r-- 501/20 6572 Apr 22 12:24 2016 compact.o/
rw-rw-r-- 501/20 4108 Apr 22 12:24 2016 finalise.o/
rw-rw-r-- 501/20 2248 Apr 22 12:24 2016 custom.o/
rw-rw-r-- 501/20 3184 Apr 22 12:24 2016 unix.o/
rw-rw-r-- 501/20 5312 Apr 22 12:24 2016 backtrace.o/
rw-rw-r-- 501/20 4124 Apr 22 12:24 2016 natdynlink.o/
rw-rw-r-- 501/20 1084 Apr 22 12:24 2016 debugger.o/
rw-rw-r-- 501/20 2036 Apr 22 12:24 2016 meta.o/
rw-rw-r-- 501/20 2100 Apr 22 12:24 2016 dynlink.o/
rw-rw-r-- 501/20 2744 Apr 22 12:24 2016 arm.o/

64 bits ARM target?

Hey,

I'm trying cross-compile to my phone running on ARM 64 but realized it is not supported yet. Just curious what would it take to support that?

Recent Android versions only support PIE executables

In Android 5.0 Google removed linker support for non-PIE (position independent executables) binaries. This causes both bytecode and native ocaml programs to fail:

root@generic:/data # ./helloworld.byte                                         
error: only position independent executables (PIE) are supported.
1|root@generic:/data # ./helloworld.native                                     
error: only position independent executables (PIE) are supported.

That was generated on a standard Google 5.0.1 image for armeabi-v7a, but the same thing happens on a Nexus 5.

A little searching around suggests that it can be tricky to support both recent and older versions of Android simultaneously because older versions don't directly support PIE, but recent versions require it. Apparently Chromium has a wrapper executable to work around this, while other people generate different executables for different versions of Android.

No ocaml-android for 64 bit? (compiling to arm64 failing)

Following the readme, I did

opam switch 4.04.0
eval `opam config env`

and then did the configure line for aarch64, but at opam install ocaml-android, I get an error indicating that ocaml-android is only compatible with a 32 bit system. (and ocaml-android is just a symlink to ocaml-android32)

Is the readme wrong?

When I try to configure for aarch64 using 4.04.0+32bit, I get a segfault when trying to run the resulting binary.

opam install fails on Fedora 21 x64

Running

"ANDROID_LEVEL=21 ANDROID_ABI=linux_eabi ANDROID_ARCH=armv7 opam install ocaml-android"

gives the following error message:

"# ERROR while installing android-ndk-linux.10d #"
"# opam-version 1.2.1~rc2"
"# os linux"
/home/steck/.opam/packages.dev/android-ndk-linux.10d/android-ndk-r10d-linux-x86.bin is not a valid tar archive.

I can unpack that archive by making it executable and running it. But I can't run tar -x on it by hand.

ctypes-android 0.6.1 fails to compile

Ok, may have an actual bug this time. ctypes 0.6.1 fails to compile. See log.

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The compilation of ctypes-android failed at "make OCAMLFIND=ocamlfind -toolchain android HOSTOCAMLFIND=ocamlfind".
Processing  1/3: [ctypes-android: ocamlfind android]
#=== ERROR while installing ctypes-android.0.6.1 ==============================#
# opam-version 1.2.2
# os           linux
# command      make OCAMLFIND=ocamlfind -toolchain android HOSTOCAMLFIND=ocamlfind
# path         /home/jesse/.opam/4.02.3+32bit/build/ctypes-android.0.6.1
# compiler     4.02.3+32bit
# exit-code    2
# env-file     /home/jesse/.opam/4.02.3+32bit/build/ctypes-android.0.6.1/ctypes-android-6990-d0f245.env
# stdout-file  /home/jesse/.opam/4.02.3+32bit/build/ctypes-android.0.6.1/ctypes-android-6990-d0f245.out
# stderr-file  /home/jesse/.opam/4.02.3+32bit/build/ctypes-android.0.6.1/ctypes-android-6990-d0f245.err
### stdout ###
# [...]
# ocamlfind -toolchain android ocamlc -package str -package bigarray -package bytes   -principal -short-paths   -c -o _build/src/ctypes/unsigned.cmo -I _build/src/ctypes  src/ctypes/unsigned.ml
# ocamlfind -toolchain android ocamlc -bin-annot -c -o _build/src/ctypes/signed.cmi -package str -package bigarray -package bytes   -principal -short-paths -I _build/src/ctypes  src/ctypes/signed.mli
# ocamlfind -toolchain android ocamlc -package str -package bigarray -package bytes   -principal -short-paths   -c -o _build/src/ctypes/signed.cmo -I _build/src/ctypes  src/ctypes/signed.ml
# ocamlfind -toolchain android ocamlc -package str -package bigarray -package bytes   -principal -short-paths   -c -o _build/src/ctypes/ctypes_ptr.cmo -I _build/src/ctypes  src/ctypes/ctypes_ptr.ml
# ocamlfind -toolchain android ocamlc -bin-annot -c -o _build/src/ctypes/ctypes_primitive_types.cmi -package str -package bigarray -package bytes   -principal -short-paths -I _build/src/ctypes  src/ctypes/ctypes_primitive_types.mli
# ocamlfind -toolchain android ocamlc -package str -package bigarray -package bytes   -principal -short-paths   -c -o _build/src/ctypes/ctypes_primitive_types.cmo -I _build/src/ctypes  src/ctypes/ctypes_primitive_types.ml
# ocamlfind -toolchain android ocamlc -package str -package bigarray -package bytes   -principal -short-paths   -c -o _build/src/ctypes/ctypes_memory_stubs.cmo -I _build/src/ctypes  src/ctypes/ctypes_memory_stubs.ml
# ocamlfind -toolchain android ocamlc -package str -package bigarray -package bytes   -principal -short-paths   -c -o _build/src/ctypes/ctypes_bigarray_stubs.cmo -I _build/src/ctypes  src/ctypes/ctypes_bigarray_stubs.ml
# ocamlfind -toolchain android ocamlc -package str -package bigarray -package bytes   -principal -short-paths   -c -o _build/src/ctypes/ctypes_primitives.cmo -I _build/src/ctypes  src/ctypes/ctypes_primitives.ml
# Makefile.rules:94: recipe for target '_build/src/ctypes/ctypes_primitives.cmo' failed
### stderr ###
# File "src/ctypes/ctypes_primitives.ml", line 1:
# Error: I/O error: src/ctypes/ctypes_primitives.ml: No such file or directory
# make: *** [_build/src/ctypes/ctypes_primitives.cmo] Error 2

Oddly running make all in the build directory seems to complete successfully.

The `-f` switch missing when install android-ndk-linux

Or something like that. Probably need to investigate

ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi \
  CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 \
  TRIPLE=arm-linux-androideabi LEVEL=24 \
  STLVER=4.9 STLARCH=armeabi \
  opam install conf-android -v
The following actions will be performed:
  ∗  install android-ndk-linux 11c            [required by conf-android]
  ∗  install conf-android      1  
===== ∗  2 =====
Do you want to continue ? [Y/n] y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ mkdir "-p" "/home/kakadu/.opam/4.04.0+32bit/android-ndk" (CWD=/home/kakadu/.opam/4.04.0+32bit/.opam-switch/build/android-ndk-linux.11c)
+ sh "-c" "mv * /home/kakadu/.opam/4.04.0+32bit/android-ndk/" (CWD=/home/kakadu/.opam/4.04.0+32bit/.opam-switch/build/android-ndk-linux.11c)
+ sh "-c" "cd /home/kakadu/.opam/4.04.0+32bit/android-ndk/ && rm android-ndk-*.env android-ndk-*.info android-ndk-*.err android-ndk-*.out" (CWD=/home/kakadu/.opam/4.04.0+32bit/.opam-switch/build/android-ndk-linux.11c)
- rm: cannot remove 'android-ndk-*.err': No such file or directory
[ERROR] The installation of android-ndk-linux failed at "sh -c cd /home/kakadu/.opam/4.04.0+32bit/android-ndk/ && rm android-ndk-*.env android-ndk-*.info android-ndk-*.err
        android-ndk-*.out".
+ rm "-rf" "/home/kakadu/.opam/4.04.0+32bit/android-ndk" (CWD=/home/kakadu/.opam/4.04.0+32bit/.opam-switch/remove/android-ndk-linux.11c)

#=== ERROR while installing android-ndk-linux.11c =============================#
# command      sh -c cd /home/kakadu/.opam/4.04.0+32bit/android-ndk/ && rm android-ndk-*.env android-ndk-*.info android-ndk-*.err android-ndk-*.out
# path         /home/kakadu/.opam/4.04.0+32bit/.opam-switch/build/android-ndk-linux.11c
# exit-code    1
# env-file     /home/kakadu/.opam/4.04.0+32bit/.opam-switch/build/android-ndk-linux.11c/android-ndk-linux-15484-6d07ae.env
# output-file  /home/kakadu/.opam/4.04.0+32bit/.opam-switch/build/android-ndk-linux.11c/android-ndk-linux-15484-6d07ae.out
### output ###
# rm: cannot remove 'android-ndk-*.err': No such file or directory



=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
┌─ The following actions were aborted
│ ∗  install conf-android 1
└─ 
┌─ The following actions failed
│ ∗  install android-ndk-linux 11c
└─ 
╶─ No changes have been performed
'opam install conf-android -v' failed.

ppx_deriving-android depends from cppo, but there is no such dependency in opam file

#=== ERROR while installing ppx_deriving-android.4.1 ==========================#
# opam-version 1.2.2
# os           linux
# command      ocaml pkg/build.ml native=true native-dynlink=true
# path         /home/guest/.opam/4.04.0+32bit/build/ppx_deriving-android.4.1
# compiler     4.04.0+32bit
# exit-code    10
# env-file     /home/guest/.opam/4.04.0+32bit/build/ppx_deriving-android.4.1/ppx_deriving-android-19956-ffb3fd.env
# stdout-file  /home/guest/.opam/4.04.0+32bit/build/ppx_deriving-android.4.1/ppx_deriving-android-19956-ffb3fd.out
# stderr-file  /home/guest/.opam/4.04.0+32bit/build/ppx_deriving-android.4.1/ppx_deriving-android-19956-ffb3fd.err
### stdout ###
# ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package cppo_ocamlbuild myocamlbuild.ml /home/guest/.opam/4.04.0+32bit/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# + ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package cppo_ocamlbuild myocamlbuild.ml /home/guest/.opam/4.04.0+32bit/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# ocamlfind: Package `cppo_ocamlbuild' not found

After I installed cppo all works well:

guest@kobyakov-pc:~$ opam install cppo -v
The following actions will be performed:
  ∗  install cppo 1.5.0
...
∗  installed cppo.1.5.0
Done.
guest@kobyakov-pc:~$ opam install ppx_deriving-android -v
The following actions will be performed:
  ∗  install ppx_deriving-android 4.1
...
- Creating directory /home/guest/.opam/4.04.0+32bit/android-sysroot/doc/ppx_deriving
- _build/CHANGELOG.md              => /home/guest/.opam/4.04.0+32bit/android-sysroot/doc/ppx_deriving/CHANGELOG.md
- _build/LICENSE.txt               => /home/guest/.opam/4.04.0+32bit/android-sysroot/doc/ppx_deriving/LICENSE.txt
- _build/README.md                 => /home/guest/.opam/4.04.0+32bit/android-sysroot/doc/ppx_deriving/README.md
∗  installed ppx_deriving-android.4.1
Done.

ocaml-android32 build error on Ubuntu 16.04

Hi there!

After fresh Ubuntu 16.04 install, having trouble getting ocaml-android32 compiled. Possibly a regex snafu in install script. It is requesting -gcc under the NDK prebuilt chain (note the dash prefix), but there is no gcc at all in the directory for any NDK version I have seen. See log below.

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The compilation of ocaml-android32 failed at "make world opt install".
Processing  1/2: [ocaml-android32: ./remove.sh]
#=== ERROR while installing ocaml-android32.4.02.3 ============================#
# opam-version 1.2.2
# os           linux
# command      make world opt install
# path         /home/jesse/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3
# compiler     4.02.3+32bit
# exit-code    2
# env-file     /home/jesse/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/ocaml-android32-24704-60459a.env
# stdout-file  /home/jesse/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/ocaml-android32-24704-60459a.out
# stderr-file  /home/jesse/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/ocaml-android32-24704-60459a.err
### stdout ###
# [...]
# cd byterun; make all
# make[2]: Entering directory '/home/jesse/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/byterun'
# sed -n -e '/^  /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \
#        -e '/^}/q' caml/instruct.h > caml/jumptbl.h
# /home/jesse/.opam/4.02.3+32bit/android-ndk/toolchains//prebuilt/linux-x86_64/bin/-gcc --sysroot /home/jesse/.opam/4.02.3+32bit/android-ndk/platforms/android-/arch- -I/home/jesse/.opam/4.02.3+32bit/android-ndk/include -L/home/jesse/.opam/4.02.3+32bit/android-ndk/lib -I/home/jesse/.opam/4.02.3+32bit/android-ndk/sources/cxx-stl/gnu-libstdc++//include -I/home/jesse/.opam/4.02.3+32bit/android-ndk/sources/cxx-stl/gnu-libstdc++//libs//include -L/home/jesse/.opam/4.02.3+32bit/android-ndk/sources/cxx-stl/gnu-libstdc++//libs/ -I/home/jesse/.opam/4.02.3+32bit/android-sysroot/include -L/home/jesse/.opam/4.02.3+32bit/android-sysroot/lib -O2 -DCAML_NAME_SPACE -fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT    -c -o interp.o interp.c
# <builtin>: recipe for target 'interp.o' failed
# make[2]: Leaving directory '/home/jesse/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/byterun'
# Makefile:188: recipe for target 'coldstart' failed
# make[1]: Leaving directory '/home/jesse/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3'
# Makefile:137: recipe for target 'world' failed
### stderr ###
# make[2]: /home/jesse/.opam/4.02.3+32bit/android-ndk/toolchains//prebuilt/linux-x86_64/bin/-gcc: Command not found
# make[2]: *** [interp.o] Error 127
# make[1]: *** [coldstart] Error 2
# make: *** [world] Error 2

Steps to reproduce:

opam init
opam switch 4.02.3+32bit
opam repo add android git://github.com/whitequark/opam-android
ANDROID_LEVEL=19 opam install ocaml-android

Any idea what is causing this?

Build failing on Debian 9 with Opam 1.2.2

I get this error when installing ocaml-android32

[ERROR] The compilation of ocaml-android32 failed at "./install.sh /root/.opam/4.04.0-armeabi".                                                               
Processing  1/1: [ocaml-android32: ./remove.sh]
#=== ERROR while installing ocaml-android32.4.04.0 ============================#                                                                              
# opam-version 1.2.2
# os           linux
# command      ./install.sh /root/.opam/4.04.0-armeabi
# path         /root/.opam/4.04.0-armeabi/build/ocaml-android32.4.04.0
# compiler     4.04.0+32bit
# exit-code    1
# env-file     /root/.opam/4.04.0-armeabi/build/ocaml-android32.4.04.0/ocaml-android32-8516-335865.env                                                        
# stdout-file  /root/.opam/4.04.0-armeabi/build/ocaml-android32.4.04.0/ocaml-android32-8516-335865.out                                                        
# stderr-file  /root/.opam/4.04.0-armeabi/build/ocaml-android32.4.04.0/ocaml-android32-8516-335865.err                                                        
### stderr ###
# cp: cannot stat '/root/.opam/4.04.0-armeabi/lib/graphics': No such file or directory                                                                        

ctypes-android 0.5.1 fails to compile

opam switch
...
4.02.3+32bit  C 4.02.3+32bit  OCaml 4.02.3 compiled in 32-bit mode for 64-bit Linux and OS X hosts
...

then

opam install ctypes-android 
The following actions will be performed:
  ∗  install ctypes-android 0.5.1

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 

#=== ERROR while installing ctypes-android.0.5.1 ==============================#
These patches didn't apply at /Users/joelr/.opam/4.02.3+32bit/build/ctypes-android.0.5.1:
  - patches/cross-compilation.patch

Am I doing something wrong? Other packages compile just fine.

Support for recent OCaml versions

I am trying to build Unison for Android, which requires OCaml >= 4.08.

Any chance of adding support for a somewhat recent OCaml version? What would it take?

ocamlbuild git url

I have a weird issue about your ocamlbuild repo. I needed to do

opam pin add ocamlbuild https://github.com/whitequark/ocamlbuild.git

instead of

opam pin add ocamlbuild https://github.com/whitequark/ocamlbuild

to compile it successfully. Don't know is it a general opam thing or opam-2.0 related.

OPAM 2 incompatibilities

Attempting to use this repository with recent OPAM (2.04) reveals a few problems. Here's a log, from the ctypes CI:

+opam remote add android git://github.com/whitequark/opam-cross-android
[android] Initialised
[WARNING] The repository 'android' at
          git://github.com/whitequark/opam-cross-android doesn't have a 'repo'
          file, and might not be compatible with this version of opam.
[WARNING] At /home/travis/.opam/repo/android/packages/csv-android.1.5/opam:2:0:
          This file is for version '1.5' but its 'version:' field advertises
          '1.3.4'.
[NOTE] Repository at git://github.com/whitequark/opam-cross-android doesn't
       define its version, assuming it's 1.2.
<><> Upgrading repositories from older opam format ><><><><><><><><><><><><><><>
Upgrading repository "android"...
[WARNING] At /home/travis/.opam/repo/android/packages/csv-android.1.5/opam:2:0:
          This file is for version '1.5' but its 'version:' field advertises
          '1.3.4'.
[ERROR] Unconvertible 'available:' disjunction in
        /home/travis/.opam/repo/android/packages/ocaml-android32.4.04.0/opam
[NOTE] Repository android has been added to the selections of switch
       4.04.0+32bit only.
       Run `opam repository add android --all-switches|--set-default' to use it
       in all existing switches, or in newly created switches, respectively.

The "Unconvertible 'available:' disjunction" is the only real problem here, but it'd be handy to have this repository upgraded for OPAM 2.

problem with lwt-android when porting to yocto/bitbake

Hello,
I'm trying to port your crosscompiler toolchain to yocto/bitbake based ARM distro.
I have slightly modified conf-android's opam file:

build: [
  ["sh" "-c" "echo \"arch: \\\"${ARCH}\\\"\" >>conf-android.config"]
  ["sh" "-c" "echo \"subarch: \\\"${SUBARCH}\\\"\" >>conf-android.config"]
  ["sh" "-c" "echo \"system: \\\"${SYSTEM}\\\"\" >>conf-android.config"]
  ["sh" "-c" "echo \"level: \\\"${LEVEL-24}\\\"\" >>conf-android.config"]
  ["sh" "-c" "echo \"triple: \\\"${TRIPLE}\\\"\" >>conf-android.config"]
  ["sh" "-c" "echo \"toolchain: \\\"/usr/bin/\\\"\" >>conf-android.config"]
  ["sh" "-c" "echo \"toolpref: \\\"/usr/bin/${TRIPLE}-\\\"\" >>conf-android.config"]
  ["sh" "-c" "echo \"cflags: \\\"--sysroot /home/dmitry/svn/wolverine/build/tmp-glibc/sysroots/wolverine_v1 -L/home/dmitry/svn/wolverine/build/tmp-glibc/sysroots/wolverine_v1/usr/lib -L/home/dmitry/svn/wolverine/build/tmp-glibc/sysroots/wolverine_v1/lib\\\"\" >>conf-android.config"]
  ["sh" "-c" "echo \"ldflags: \\\"--sysroot /home/dmitry/svn/wolverine/build/tmp-glibc/sysroots/wolverine_v1 -L/home/dmitry/svn/wolverine/build/tmp-glibc/sysroots/wolverine_v1/usr/lib -L/home/dmitry/svn/wolverine/build/tmp-glibc/sysroots/wolverine_v1/lib\\\"\" >>conf-android.config"]

pin it and successfully built ocaml-android for ARM:

ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi \
  CCARCH=arm TOOLCHAIN=arm-oe-linux-gnueabi \
  TRIPLE=arm-oe-linux-gnueabi LEVEL=24 \
  STLVER=4.9 STLARCH=armeabi \
  opam install conf-android
opam install ocaml-android
opam install re-android

Simple tests such as helloworld.ml and test_pcre.ml were crosscompiled nicely an work well on target machine.
But when I tryed to install lwt-android I got:

[ERROR] The compilation of lwt-android failed at "env OCAMLFIND_TOOLCHAIN=android ocaml setup.ml
        -configure --prefix /home/guest/.opam/4.04.0+32bit --disable-libev --disable-react
        --disable-ssl --enable-unix --enable-preemptive --enable-android-target".
Processing  1/1: [lwt-android: ocamlfind android]
#=== ERROR while installing lwt-android.2.6.0 =================================#
# opam-version 1.2.2
# os           linux
# command      env OCAMLFIND_TOOLCHAIN=android ocaml setup.ml -configure --prefix /home/guest/.opam/4.04.0+32bit --disable-libev --disable-react --disable-ssl --enable-unix --enable-preemptive --enable-android-target
# path         /home/guest/.opam/4.04.0+32bit/build/lwt-android.2.6.0
# compiler     4.04.0+32bit
# exit-code    1
...
# Missing C libraries: pthread
### stderr ###
# E: Failure("Command 'ocaml utils/discover.ml -ext-obj .o -exec-name a.out -use-libev false -os-type Unix -use-glib false -ccomp-type cc -use-pthread true -use-unix true -android-target true -libev_default true' terminated with error code 1")

I've tried to setup CC,LD,CPP,CFLAGS, LDFLAGS and PTHREAD_CFLAGS with PTHREAD_LIBS environment variables by hand but nothing changed.
Of course, I can cross compile test for pthread from setup.ml by hands without any errors.

I suppose, after I install conf-android, I should see file conf-android.config somewhere in .opam as it written due build stage, but there is no such file. Isn't it root of my problems?

Failure on darwin

/Users/dbuenzli/.opam/4.02.3+32bit/lib/android-ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86/bin/arm-linux-androideabi-ranlib: libcamlrun_pic.a: Malformed archive
# make[1]: *** [install-shared] Error 1

This is due to a hardcoded uses of ar see ocaml/ocaml#249, could you maybe integrate the patch in the package ?

ocamlobjinfo's helper's program cannot be executed on the build-os

ocamlobjinfo uses a helper program that is written in C and installed in lib. In opam-android this gets compiled with the cross-complier and thus cannot be executed on the build-os.

It seems that this helper program is used for .cmxs files which are not supported by opam-android but if you try to execute it on other .cmxs files this gives the following:

> ./ocamlobjinfo ~/.opam/4.02.3/lib/uutf/uutf.cmxs
File /Users/dbuenzli/.opam/4.02.3/lib/uutf/uutf.cmxs
sh: /Users/dbuenzli/.opam/4.02.3+32bit/arm-linux-androideabi/lib/ocaml/objinfo_helper: cannot execute binary file
Unable to read info on file /Users/dbuenzli/.opam/4.02.3/lib/uutf/uutf.cmxs

Some packages do not build on OS X host


+ opam='env ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi   CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9   TRIPLE=arm-linux-androideabi LEVEL=15 opam'
+ env ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 TRIPLE=arm-linux-androideabi LEVEL=15 opam update

=-=- Updating package repositories =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[android] git://github.com/whitequark/opam-cross-android already up-to-date
[windows] git://github.com/whitequark/opam-cross-windows already up-to-date
[default] synchronized from https://opam.ocaml.org
+ env ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 TRIPLE=arm-linux-androideabi LEVEL=15 opam upgrade
Everything as up-to-date as possible (run with --verbose to show unavailable upgrades).
+ env ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabi CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 TRIPLE=arm-linux-androideabi LEVEL=15 opam install --yes ocaml-android biniou-android easy-format-android yojson-android camlzip-android camlbz2-android camlimages-android proj4-android expat-android
[NOTE] Package ocaml-android is already installed (current version is 4.02.3).
[NOTE] Package easy-format-android is already installed (current version is 1.2.0).
[NOTE] Package camlzip-android is already installed (current version is 1.05).
[NOTE] Package camlbz2-android is already installed (current version is 0.6.0).
The following actions will be performed:
  - install freetype-sys-android 2.6.3                  [required by camlimages-android]
  - install expat-sys-android    2.1.1                  [required by expat-android]
  - install biniou-android       1.0.10
  - install libjpeg-sys-android  9b                     [required by camlimages-android]
  - install proj4-sys-android    4.9.2                  [required by proj4-android]
  - install expat-android        0.9.1 
  - install yojson-android       1.3.2 
  - install camlimages-android   4.2.1 
  - install proj4-android        0.9.1 
===== 9 to install =====

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[expat-android.0.9.1] http://mmzeeman.home.xs4all.nl/ocaml/ocaml-expat-0.9.1.tar.gz downloaded
[biniou-android.1.0.10] https://github.com/mjambon/biniou/archive/v1.0.10.tar.gz downloaded
[expat-sys-android.2.1.1] http://downloads.sourceforge.net/project/expat/expat/2.1.1/expat-2.1.1.tar.bz2 downloaded
[libjpeg-sys-android.9b] http://www.ijg.org/files/jpegsrc.v9b.tar.gz downloaded
[proj4-android.0.9.1] https://github.com/hcarty/proj4ml/archive/v0.9.1.tar.gz downloaded
[freetype-sys-android.2.6.3] http://download.savannah.gnu.org/releases/freetype/freetype-2.6.3.tar.bz2 downloaded
[camlimages-android.4.2.1] https://bitbucket.org/camlspotter/camlimages/get/4.2.1.tar.gz downloaded
[yojson-android.1.3.2] https://github.com/mjambon/yojson/archive/v1.3.2.tar.gz downloaded
[proj4-sys-android.4.9.2] https://github.com/OSGeo/proj.4/archive/4.9.2.tar.gz downloaded

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The compilation of biniou-android failed at "env OCAMLFIND_TOOLCHAIN=android make".
[ERROR] The compilation of expat-sys-android failed at "./configure --host=arm-linux-androideabi
        --prefix=/Users/mhayden/.opam/4.02.3+32bit/android-deps/expat --disable-shared --with-pic
        PATH=/Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/:/usr/bin:/bin CFLAGS=--sysroot
        /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -I/Users/mhayden/.opam/4.02.3+32bit/android-ndk/include
        -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -I/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/include
        -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib LDFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm
        -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib".
[ERROR] The compilation of freetype-sys-android failed at "./configure --host=arm-linux-androideabi
        --prefix=/Users/mhayden/.opam/4.02.3+32bit/android-deps/freetype --disable-shared --with-pic --with-harfbuzz=no
        PATH=/Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/:/usr/bin:/bin CFLAGS=--sysroot
        /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -I/Users/mhayden/.opam/4.02.3+32bit/android-ndk/include
        -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -I/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/include
        -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib LDFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm
        -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib
        PKG_CONFIG_LIBDIR=/Users/mhayden/.opam/4.02.3+32bit/android-deps/libpng/lib/pkgconfig ZLIB_CFLAGS= ZLIB_LIBS=-lz
        BZIP2_CFLAGS=-I/Users/mhayden/.opam/4.02.3+32bit/android-deps/bzip2/include BZIP2_LIBS=-L/Users/mhayden/.opam/4.02.3+32bit/android-deps/bzip2/lib".
[ERROR] The compilation of libjpeg-sys-android failed at "./configure --host=arm-linux-androideabi
        --prefix=/Users/mhayden/.opam/4.02.3+32bit/android-deps/libjpeg --disable-shared --with-pic
        PATH=/Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/:/usr/bin:/bin CFLAGS=--sysroot
        /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -I/Users/mhayden/.opam/4.02.3+32bit/android-ndk/include
        -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -I/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/include
        -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib LDFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm
        -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib".
[ERROR] The compilation of proj4-sys-android failed at "./configure --host=arm-linux-androideabi
        --prefix=/Users/mhayden/.opam/4.02.3+32bit/android-deps/proj4 --disable-shared --with-pic --without-jni
        PATH=/Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/:/usr/bin:/bin CFLAGS=--sysroot
        /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -I/Users/mhayden/.opam/4.02.3+32bit/android-ndk/include
        -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -I/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/include
        -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib LDFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm
        -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib".
Processing  7/9: [proj4-sys-android: rm]
#=== ERROR while installing biniou-android.1.0.10 =============================#
# opam-version 1.2.2
# os           darwin
# command      env OCAMLFIND_TOOLCHAIN=android make
# path         /Users/mhayden/.opam/4.02.3+32bit/build/biniou-android.1.0.10
# compiler     4.02.3+32bit
# exit-code    2
# env-file     /Users/mhayden/.opam/4.02.3+32bit/build/biniou-android.1.0.10/biniou-android-15420-b76d46.env
# stdout-file  /Users/mhayden/.opam/4.02.3+32bit/build/biniou-android.1.0.10/biniou-android-15420-b76d46.out
# stderr-file  /Users/mhayden/.opam/4.02.3+32bit/build/biniou-android.1.0.10/biniou-android-15420-b76d46.err
### stdout ###
# ocamlfind ocamlc -a -g -annot -bin-annot -o biniou.cma \
#       -package "easy-format" bi_util.mli bi_util.ml bi_share.mli bi_share.ml bi_outbuf.mli bi_outbuf.ml bi_inbuf.mli bi_inbuf.ml bi_vint.mli bi_vint.ml bi_io.mli bi_io.ml bi_dump.ml bi_stream.mli bi_stream.ml
# ocamlfind ocamlc -o bdump.byte -g -annot -bin-annot \
#       -package easy-format -linkpkg biniou.cma bdump.ml
# mkdir -p doc
# ocamlfind ocamldoc -d doc -html -package easy-format bi_util.mli bi_share.mli bi_outbuf.mli bi_inbuf.mli bi_vint.mli bi_io.mli bi_stream.mli
# sed -e 's:@@VERSION@@:1.0.10:' META.in > META
# cp  test_biniou
### stderr ###
# [...]
# Use Bytes.create instead.
# File "bi_stream.ml", line 56, characters 16-29:
# Warning 3: deprecated: String.create
# Use Bytes.create instead.
# make: Circular bdump.ml <- bdump.ml dependency dropped.
# make: Circular META.in <- META.in dependency dropped.
# make: Circular test_biniou <- test_biniou dependency dropped.
# usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
#        cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
# make: *** [test_biniou] Error 64


#=== ERROR while installing expat-sys-android.2.1.1 ===========================#
# opam-version 1.2.2
# os           darwin
# command      ./configure --host=arm-linux-androideabi --prefix=/Users/mhayden/.opam/4.02.3+32bit/android-deps/expat --disable-shared --with-pic PATH=/Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/:/usr/bin:/bin CFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -I/Users/mhayden/.opam/4.02.3+32bit/android-ndk/include -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -I/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/include -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib LDFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib
# path         /Users/mhayden/.opam/4.02.3+32bit/build/expat-sys-android.2.1.1
# compiler     4.02.3+32bit
# exit-code    1
# env-file     /Users/mhayden/.opam/4.02.3+32bit/build/expat-sys-android.2.1.1/expat-sys-android-15420-dc6e87.env
# stdout-file  /Users/mhayden/.opam/4.02.3+32bit/build/expat-sys-android.2.1.1/expat-sys-android-15420-dc6e87.out
# stderr-file  /Users/mhayden/.opam/4.02.3+32bit/build/expat-sys-android.2.1.1/expat-sys-android-15420-dc6e87.err
### stdout ###
# [...]
# checking for gawk... no
# checking for mawk... no
# checking for nawk... no
# checking for awk... awk
# checking command to parse /Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin//arm-linux-androideabi-nm -B output from arm-linux-androideabi-gcc object... ok
# checking for sysroot... no
# checking for arm-linux-androideabi-mt... no
# checking for mt... no
# checking if : is a manifest tool... no
# checking how to run the C preprocessor... /lib/cpp
### stderr ###
# configure: error: in `/Users/mhayden/.opam/4.02.3+32bit/build/expat-sys-android.2.1.1':
# configure: error: C preprocessor "/lib/cpp" fails sanity check
# See `config.log' for more details


#=== ERROR while installing freetype-sys-android.2.6.3 ========================#
# opam-version 1.2.2
# os           darwin
# command      ./configure --host=arm-linux-androideabi --prefix=/Users/mhayden/.opam/4.02.3+32bit/android-deps/freetype --disable-shared --with-pic --with-harfbuzz=no PATH=/Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/:/usr/bin:/bin CFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -I/Users/mhayden/.opam/4.02.3+32bit/android-ndk/include -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -I/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/include -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib LDFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib PKG_CONFIG_LIBDIR=/Users/mhayden/.opam/4.02.3+32bit/android-deps/libpng/lib/pkgconfig ZLIB_CFLAGS= ZLIB_LIBS=-lz BZIP2_CFLAGS=-I/Users/mhayden/.opam/4.02.3+32bit/android-deps/bzip2/include BZIP2_LIBS=-L/Users/mhayden/.opam/4.02.3+32bit/android-deps/bzip2/lib
# path         /Users/mhayden/.opam/4.02.3+32bit/build/freetype-sys-android.2.6.3
# compiler     4.02.3+32bit
# exit-code    2
# env-file     /Users/mhayden/.opam/4.02.3+32bit/build/freetype-sys-android.2.6.3/freetype-sys-android-15420-6aa130.env
# stdout-file  /Users/mhayden/.opam/4.02.3+32bit/build/freetype-sys-android.2.6.3/freetype-sys-android-15420-6aa130.out
# stderr-file  /Users/mhayden/.opam/4.02.3+32bit/build/freetype-sys-android.2.6.3/freetype-sys-android-15420-6aa130.err
### stdout ###
# [...]
# checking for arm-linux-androideabi-gcc... arm-linux-androideabi-gcc
# checking whether the C compiler works... yes
# checking for C compiler default output file name... a.out
# checking for suffix of executables... 
# checking whether we are cross compiling... yes
# checking for suffix of object files... o
# checking whether we are using the GNU C compiler... yes
# checking whether arm-linux-androideabi-gcc accepts -g... yes
# checking for arm-linux-androideabi-gcc option to accept ISO C89... none needed
# checking how to run the C preprocessor... /lib/cpp
### stderr ###
# configure: error: in `/Users/mhayden/.opam/4.02.3+32bit/build/freetype-sys-android.2.6.3/builds/unix':
# configure: error: C preprocessor "/lib/cpp" fails sanity check
# See `config.log' for more details
# make: *** [setup] Error 1


#=== ERROR while installing libjpeg-sys-android.9b ============================#
# opam-version 1.2.2
# os           darwin
# command      ./configure --host=arm-linux-androideabi --prefix=/Users/mhayden/.opam/4.02.3+32bit/android-deps/libjpeg --disable-shared --with-pic PATH=/Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/:/usr/bin:/bin CFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -I/Users/mhayden/.opam/4.02.3+32bit/android-ndk/include -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -I/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/include -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib LDFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib
# path         /Users/mhayden/.opam/4.02.3+32bit/build/libjpeg-sys-android.9b
# compiler     4.02.3+32bit
# exit-code    1
# env-file     /Users/mhayden/.opam/4.02.3+32bit/build/libjpeg-sys-android.9b/libjpeg-sys-android-15420-0325cb.env
# stdout-file  /Users/mhayden/.opam/4.02.3+32bit/build/libjpeg-sys-android.9b/libjpeg-sys-android-15420-0325cb.out
# stderr-file  /Users/mhayden/.opam/4.02.3+32bit/build/libjpeg-sys-android.9b/libjpeg-sys-android-15420-0325cb.err
### stdout ###
# [...]
# checking for suffix of object files... o
# checking whether we are using the GNU C compiler... yes
# checking whether arm-linux-androideabi-gcc accepts -g... yes
# checking for arm-linux-androideabi-gcc option to accept ISO C89... none needed
# checking whether arm-linux-androideabi-gcc understands -c and -o together... yes
# checking for style of include used by make... GNU
# checking dependency style of arm-linux-androideabi-gcc... gcc3
# checking for arm-linux-androideabi-gcc option to accept ISO C99... -std=gnu99
# checking for arm-linux-androideabi-gcc -std=gnu99 option to accept ISO Standard C... (cached) -std=gnu99
# checking how to run the C preprocessor... /lib/cpp
### stderr ###
# configure: error: in `/Users/mhayden/.opam/4.02.3+32bit/build/libjpeg-sys-android.9b':
# configure: error: C preprocessor "/lib/cpp" fails sanity check
# See `config.log' for more details


#=== ERROR while installing proj4-sys-android.4.9.2 ===========================#
# opam-version 1.2.2
# os           darwin
# command      ./configure --host=arm-linux-androideabi --prefix=/Users/mhayden/.opam/4.02.3+32bit/android-deps/proj4 --disable-shared --with-pic --without-jni PATH=/Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/:/usr/bin:/bin CFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -I/Users/mhayden/.opam/4.02.3+32bit/android-ndk/include -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -I/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/include -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib LDFLAGS=--sysroot /Users/mhayden/.opam/4.02.3+32bit/android-ndk/platforms/android-15/arch-arm -L/Users/mhayden/.opam/4.02.3+32bit/android-ndk/lib -L/Users/mhayden/.opam/4.02.3+32bit/android-sysroot/lib
# path         /Users/mhayden/.opam/4.02.3+32bit/build/proj4-sys-android.4.9.2
# compiler     4.02.3+32bit
# exit-code    1
# env-file     /Users/mhayden/.opam/4.02.3+32bit/build/proj4-sys-android.4.9.2/proj4-sys-android-15420-e0ba4f.env
# stdout-file  /Users/mhayden/.opam/4.02.3+32bit/build/proj4-sys-android.4.9.2/proj4-sys-android-15420-e0ba4f.out
# stderr-file  /Users/mhayden/.opam/4.02.3+32bit/build/proj4-sys-android.4.9.2/proj4-sys-android-15420-e0ba4f.err
### stdout ###
# [...]
# checking for arm-linux-androideabi-ar... arm-linux-androideabi-ar
# checking for archiver @FILE support... @
# checking for arm-linux-androideabi-strip... (cached) arm-linux-androideabi-strip
# checking for arm-linux-androideabi-ranlib... arm-linux-androideabi-ranlib
# checking command to parse /Users/mhayden/.opam/4.02.3+32bit/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin//arm-linux-androideabi-nm -B output from arm-linux-androideabi-gcc object... ok
# checking for sysroot... no
# checking for arm-linux-androideabi-mt... no
# checking for mt... no
# checking if : is a manifest tool... no
# checking how to run the C preprocessor... /lib/cpp
### stderr ###
# /Users/mhayden/.opam/4.02.3+32bit/build/proj4-sys-android.4.9.2/missing: Unknown `--is-lightweight' option
# Try `/Users/mhayden/.opam/4.02.3+32bit/build/proj4-sys-android.4.9.2/missing --help' for more information
# configure: WARNING: 'missing' script is too old or missing
# configure: error: in `/Users/mhayden/.opam/4.02.3+32bit/build/proj4-sys-android.4.9.2':
# configure: error: C preprocessor "/lib/cpp" fails sanity check
# See `config.log' for more details



=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions were aborted
  - install camlimages-android 4.2.1
  - install expat-android      0.9.1
  - install proj4-android      0.9.1
  - install yojson-android     1.3.2
The following actions failed
  - install biniou-android       1.0.10
  - install expat-sys-android    2.1.1 
  - install freetype-sys-android 2.6.3 
  - install libjpeg-sys-android  9b    
  - install proj4-sys-android    4.9.2 
No changes have been performed
sakhalin% 

Can't install conf-android on 32-bit system

I'm use Ubuntu 14.04 LTS 32-bit version.
ARCH=arm SUBARCH=armv7 SYSTEM=linux_eabihf CCARCH=arm TOOLCHAIN=arm-linux-androideabi-4.9 TRIPLE=arm-linux-androideabi STLVER=4.9 STLARCH=armeabi opam install conf-android
says

The following dependencies couldn't be met:
  - conf-android -> android-ndk-darwin >= 11c
  - conf-android -> android-ndk-linux >= 11c
Your request can't be satisfied:
  - android-ndk-darwin>=11c is not available because your system doesn't comply with os = "darwin".
  - android-ndk-linux>=11c is not available because your system doesn't comply with os = "linux" & arch = "x86_64".

I've played with LEVEL=[9.. 11] and TOOLCHAIN=arm-linux-androideabi-[4.6 .. 4.9] but it not resolved my problem.
How should I install conf-android on 32-bit host machines?

building on MacOS

I am building on up-to-date MacOS system. Trying to build 4.02.3 stop on the error below, apparently in building ocamldoc. Undoing part of the recent change to enable OCAMLDOC (in Makefile.in) seems to be a work-around.

best, Mark

WITH_DEBUGGER=ocamldebugger
#WITH_OCAMLDOC=ocamldoc
WITH_OCAMLBUILD=





The following actions will be performed:
  - install ocaml-android32 4.02.3                      [required by ocaml-android]
  - install ocaml-android   4.02.3
===== 2 to install =====
Do you want to continue ? [Y/n] y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ocaml-android32.4.02.3] http://caml.inria.fr/pub/distrib/ocaml-4.02/ocaml-4.02.3.tar.gz downloaded

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The compilation of ocaml-android32 failed at "make world opt install".
Processing  1/2: [ocaml-android32: ./remove.sh]
#=== ERROR while installing ocaml-android32.4.02.3 ============================#
# opam-version 1.2.2
# os           darwin
# command      make world opt install
# path         /Users/mhayden/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3
# compiler     4.02.3+32bit
# exit-code    2
# env-file     /Users/mhayden/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/ocaml-android32-43747-c743ac.env
# stdout-file  /Users/mhayden/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/ocaml-android32-43747-c743ac.out
# stderr-file  /Users/mhayden/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/ocaml-android32-43747-c743ac.err
### stdout ###
# [...]
# ../stdlib/*.mli ../parsing/*.mli ../otherlibs/unix/unix.mli ../otherlibs/str/str.mli ../otherlibs/bigarray/bigarray.mli ../otherlibs/num/num.mli
# Makefile:313: recipe for target 'stdlib_man/Pervasives.3o' failed
# make[4]: Leaving directory '/Users/mhayden/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/ocamldoc'
# Makefile:158: recipe for target 'all' failed
# make[3]: Leaving directory '/Users/mhayden/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3/ocamldoc'
# Makefile:738: recipe for target 'ocamldoc' failed
# make[2]: Leaving directory '/Users/mhayden/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3'
# Makefile:129: recipe for target 'all' failed
# make[1]: Leaving directory '/Users/mhayden/.opam/4.02.3+32bit/build/ocaml-android32.4.02.3'
# Makefile:137: recipe for target 'world' failed
### stderr ###
# md5.c:215:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
# [...]
#      ^
#5 shift/reduce conflicts.

Support for several ABIs

The toolchain is currently configured to target the ARMv5TE architecture.

It should be possible to generate ARMv7 code as well, as it is supported by most Android devices, uses hard floating points, and is more compact (OCaml will generate Thumb-2 instructions by default). You can have a look at how https://github.com/vouillon/ocaml-android does it. I think the selection should be done through an environment variable as with ANDROID_LEVEL.

The x86 architecture should be supported as well.

A concern is that the Android NDK is going to be duplicated for each all compiler. Maybe one can just extract the relevant platform and toolchain?

Documentation is missing an example

Hi; I find both this and your iOS cross compiler very difficult to use as there is no examples on how to actually call ocaml code from e.g. an android activities. It would be extremely helpful if such examples was included!

README improvements

There is a typo opam ocaml-android replace it with opam install ocaml-android.

The .native and .byte compilation commands seem to be swapped (ocamlc should be used for .byte).

Please add a note about approximate disk space requirements, for example the ~/.opam/4.02.1+32bit directory was 3.4G for me (which is completely fine, but would be nice to know about it).

Please document how to change ANDROID_LEVEL: it defaults to 19, but I wanted to use level 9. I have manually edited the opam file and removed state.cache and did an opam install ocaml-android32, but there is probably a better way, could the opam file accept an env var for example?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.