# Julia on iOS and Android

**URL:** <https://discourse.julialang.org/t/julia-on-ios-and-android/7346>\
**Category:** Internals & Design\
**Tags:** android\
**Created:** [November 28, 2017, 3:23am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346 "2017-11-28T03:23:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pitao/32/116_2.png) [@pitao](https://discourse.julialang.org/u/pitao)\
**Post date:** [November 28, 2017, 3:23am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/1 "2017-11-28T03:23:29Z")

</div>

Can anyone see any path towards running Julia code on iOS / Android?

It would be fantastic to be able to solve the two-language problem (e.g. prototyping in Python and deploying in C++).

The idea would be to release an app on the app-store that contains a Julia kernel.

Would it be possible to get Julia to precompile the Julia code, so that it generates a binary library exposing C-style functions, and the iOS/Android code could link against this library?

Something like this could massively accelerate the development of apps that require complex mathematics.

And how about the full-blown Julia process of dynamic compilation? Apple has a ‘no compilers’ rule but IIRC it has allowed many apps that violate this rule in the past. If the app consumer is allowed to write and execute arbitrary Julia code this may fall foul, but if the developer is the only one writing the Julia code then Apple may be willing to allow it.

π

---

<div class="post-metadata">

**Author:** ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)\
**Post date:** [November 28, 2017, 5:36am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/2 "2017-11-28T05:36:58Z")

</div>

I use Julia on Android but it is not a direct way because Android’s own libc and ABI is not compatible with Julia’s generic binaries. However, having small linux directory and using `proot` through `termux` terminal app I can use Julia as if I am in regular linux. Some functions are not still usable but computationally I did not see any unusable features. Also, I use `IJulia` to interface Julia to a browser app instead of terminal screen.  
Nontheless, this way may not work in the future Android releases as google restricts more user space features and deviates from regular linux.

---

<div class="post-metadata">

**Author:** ![its-pointless](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/its-pointless/32/3934_2.png) [@its-pointless](https://discourse.julialang.org/u/its-pointless)\
**Post date:** [April 12, 2018, 11:56am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/3 "2018-04-12T11:56:43Z")

</div>

I have it running natively compiled using termux.

---

<div class="post-metadata">

**Author:** ![pitao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pitao/32/116_2.png) [@pitao](https://discourse.julialang.org/u/pitao)\
**Post date:** [April 12, 2018, 12:08pm UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/4 "2018-04-12T12:08:02Z")

</div>

Could you say more? You have it running on both iOS _and_ Android? Could you detail the process?

Has anyone managed iOS?

---

<div class="post-metadata">

**Author:** ![its-pointless](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/its-pointless/32/3934_2.png) [@its-pointless](https://discourse.julialang.org/u/its-pointless)\
**Post date:** [April 12, 2018, 12:16pm UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/5 "2018-04-12T12:16:05Z")

</div>

Just android.  
ios would he a lot harder due to the restrictions they have on apps and executing native code.

---

<div class="post-metadata">

**Author:** ![its-pointless](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/its-pointless/32/3934_2.png) [@its-pointless](https://discourse.julialang.org/u/its-pointless)\
**Post date:** [April 12, 2018, 12:30pm UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/6 "2018-04-12T12:30:47Z")

</div>

i have a github account with a fork of julia. Termux provides a llvm clang etc and i have added gcc with gfortran and openblas. etc  
This allows me to compile julia on device. Unless someone with more knowledge of Julia than i can get cross compiling working ( there is one guy trying afaik ) what i have done is the best there is for now with regards to geting julia that runs on the bionic libc aka real android.

---

<div class="post-metadata">

**Author:** ![jballanc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jballanc/32/328_2.png) [@jballanc](https://discourse.julialang.org/u/jballanc)\
**Post date:** [April 12, 2018, 3:57pm UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/7 "2018-04-12T15:57:26Z")

</div>

The issue you’re going to run into with iOS is not App Store restrictions, but the fact that you cannot mark writable memory pages as executable. This is a security “feature”, but also means that any sort of JIT compilation just plain does not work.

---

<div class="post-metadata">

**Author:** ![pitao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pitao/32/116_2.png) [@pitao](https://discourse.julialang.org/u/pitao)\
**Post date:** [April 12, 2018, 4:06pm UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/8 "2018-04-12T16:06:03Z")

</div>

That’s a good knowledge.

Should it be possible to precompile Julia code & ship the binary on iOS?

Basically I’m designing a complex algorithm that ships as a (binary) library. I’m currently prototyping in Python and then coding up in C++.

It would be fantastic if I was able to simply code it up in Julia.

---

<div class="post-metadata">

**Author:** ![jballanc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jballanc/32/328_2.png) [@jballanc](https://discourse.julialang.org/u/jballanc)\
**Post date:** [April 12, 2018, 4:13pm UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/9 "2018-04-12T16:13:38Z")

</div>

In theory, yes, there should be no issue with shipping a compiled binary.

(BTW, for background I used to work on MacRuby and am familiar with the techniques that had to be employed for RubyMotion to deploy on iOS.)

The problem, of course, is maintaining dynamism while doing so. If all your types are specified in advance, it’s no problem. If not, then you need to (re-)implement dynamic dispatch that doesn’t require JIT’ing. See [here](https://www.mikeash.com/pyblog/friday-qa-2014-07-04-secrets-of-swifts-speed.html) for a (very advanced) dive into how Obj-C and Swift handle dynamic dispatch differently.

---

<div class="post-metadata">

**Author:** ![pitao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pitao/32/116_2.png) [@pitao](https://discourse.julialang.org/u/pitao)\
**Post date:** [April 21, 2018, 8:37pm UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/10 "2018-04-21T20:37:52Z")

</div>

I’m crosslinking [Building -- and releasing -- a fully self-contained Application written in julia](https://discourse.julialang.org/t/building-and-releasing-a-fully-self-contained-application-written-in-julia/10418)

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [May 3, 2018, 4:59am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/11 "2018-05-03T04:59:31Z")

</div>

Hello its-pointless, could you please tell me how did you install gfortran on your device? termux doesn’t have gfortran, libatomic nor awk, which are build dependencies too.

---

<div class="post-metadata">

**Author:** ![its-pointless](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/its-pointless/32/3934_2.png) [@its-pointless](https://discourse.julialang.org/u/its-pointless)\
**Post date:** [May 3, 2018, 5:11am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/12 "2018-05-03T05:11:17Z")

</div>

sure i have a seperate repo with all the needed packages at [https://github.com/its-pointless/gcc\_termux](https://github.com/its-pointless/gcc_termux) if you follow instructions in README.txt its relatively straight forward. From there you can install julia directly or you can clone [https://github.com/its-pointless/julia](https://github.com/its-pointless/julia) and build it yourself.

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [May 3, 2018, 5:13am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/13 "2018-05-03T05:13:35Z")

</div>

I’m cloning your julia fork, I’m exited! 🙂 Thanks!

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [May 3, 2018, 5:53am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/14 "2018-05-03T05:53:55Z")

</div>

I’m getting uv.h not found, and “cannot find lbthread”, I’m reading all your comments I can find, but I’m not sure how to proceed. 😮

I’m stuck at the run: “setupclang and setupgcc-7” I don’t understand where should I get those commands.

---

<div class="post-metadata">

**Author:** ![its-pointless](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/its-pointless/32/3934_2.png) [@its-pointless](https://discourse.julialang.org/u/its-pointless)\
**Post date:** [May 3, 2018, 6:07am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/15 "2018-05-03T06:07:14Z")

</div>

need to install bthread-dev. Its a pthread-cancel implementation for android. Its needed for julia’s libuv which is different.  
The command  
./buildjulia-termux.sh  
should be enough as long as you installed the dependencies. Or i failed. One of those ones.

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [May 3, 2018, 6:31am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/16 "2018-05-03T06:31:05Z")

</div>

After installing that I’m getting this new error:

# clang

```julia-auto
ln -sf /data/data/com.termux/files/usr/lib/libmpfr.so /data/data/com.termux/files/home/bin/julia/usr/lib/julia
    CC src/APInt-C.o
clang-6.0: warning: optimization flag '-falign-functions' is not supported [-Wignored-optimization-argument]
In file included from /data/data/com.termux/files/home/bin/julia/src/APInt-C.cpp:3:
./llvm-version.h:3:10: fatal error: 'llvm/Config/llvm-config.h' file not found
#include <llvm/Config/llvm-config.h>
         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.
make[1]: *** [Makefile:136: APInt-C.o] Error 1
make: *** [Makefile:97: julia-src-release] Error 2
$

```

* * *

# gcc

```julia-auto
 ln -sf /data/data/com.termux/files/usr/lib/libmpfr.so /data/data/com.termux/files/home/bin/julia/usr/lib/julia CC src/APInt-C.o
g++: warning: unrecognized command line option '-Wcovered-switch-default'; did you mean '-Wno-switch-defaul'?
g++: warning: unrecognized command line option '-Wstring-conversion'; did you mean '-Wint-conversion'?
cc1plus: error: unrecognized command line option '-Wcovered-switch-default'
cc1plus: error: unrecognized command line option '-Wstring-conversion'
make[1]: *** [Makefile:136: APInt-C.o] Error 1
make: *** [Makefile:97: julia-src-release] Error 2
$

```

---

<div class="post-metadata">

**Author:** ![its-pointless](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/its-pointless/32/3934_2.png) [@its-pointless](https://discourse.julialang.org/u/its-pointless)\
**Post date:** [May 3, 2018, 6:33am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/17 "2018-05-03T06:33:20Z")

</div>

yeah probably need all the llvm bits as well  
libllvm-dev llvm libclang-dev etc

setupclang-gfort-7  
is you want to run before you execute the script

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [May 3, 2018, 6:44am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/18 "2018-05-03T06:44:31Z")

</div>

I really really apreciate all your help, I know that all this must seem implicit to you, but I promise I’ll make a blog post to document it, this is truly awesome. ✨

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [May 3, 2018, 6:50am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/19 "2018-05-03T06:50:05Z")

</div>

Oh god, this one is more cryptic:

```julia
Segmentation fault                           
make[1]: *** [Makefile:187: /data/data/com.termux/files/home/bin/julia/usr/lib/julia/libgit2.so] Error 139 
make: *** [Makefile:91: julia-base] Error 2           
$

```

---

<div class="post-metadata">

**Author:** ![its-pointless](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/its-pointless/32/3934_2.png) [@its-pointless](https://discourse.julialang.org/u/its-pointless)\
**Post date:** [May 3, 2018, 6:52am UTC](https://discourse.julialang.org/t/julia-on-ios-and-android/7346/20 "2018-05-03T06:52:28Z")

</div>

need to install system libgit2-dev ?

[Next page](https://discourse.julialang.org/t/julia-on-ios-and-android/7346.md?page=2)
