Build Erlang like static library for iOS/Android. How?

Hello all!

Trying to find any info about building Erlang like static library for iOS/Android. Is there any? The global goal is attempt to write mobile client for iOS/Android with Qt/QML/C++. My second field of expertise, beside of Erlang - developing mobile application for iOS/Android with Qt/QML/C++. There are small channel on Youtube created by me with Qt examples for mobile.

The global case for it is using mobile phone for interacting with Erlang nodes. For implementing it with Qt/QML/C++ Erlang has to be built like static library for iOS/Android.

The only things available for me now is:

Is there anybody who has real world experience of building Erlang for iOS/Android?

In Github Erlang repo presented few configs for building it for iOS and Android, but haven’t found about building it like static library.

1 Like

Maybe not exactly what you’re looking for, but Erlang runs in Termux. Erlang/OTP is available as a binary package for Android, no assembly required.
From what I know, running any interpreter except Safari JavaScript on iOS is totally verboten due to totalitarian nature of the company behind this OS. Android is catching up on the whole freedom hating front, but it’s not quite there yet.

3 Likes

Is it enough to use this library like Erlang static library?

1 Like

Take a look at GitHub - elixir-desktop/runtimes: Erlang / Elixir runtimes for Android and iOS

2 Likes

Hi alexandr,

the elixir-desktop/runtimes are maybe little bit too old for the new requirements from Google. All new apps since 1. Nov. 2025 in the Play Store must be 16 kb page size compatible - https://developer.android.com/guide/practices/page-sizes - I don´t know if this is currently up to date, because I am compiling it for Android on my self.

for Android I am using a compiled erlang version on my Linux Server with the Android NDK. On iOS I am compiling it with Xcode Command Line Tools and creating finally a liberlang.a file.

Are you intend to use OpenSSL / Crypto in Erlang for Android / iOS - it belongs to build Android / iOS Version for OpenSSL and Erlang?

e.g. compiling without SSL on Mac for iOS:
compile_erlang.sh

#!/bin/bash
set -xeuo pipefail

(
./otp_build configure
–prefix=$(pwd)/\_build/ios64
–xcomp-conf=./xcomp/erl-xcomp-arm64-ios.conf
–without-ssl

./otp_build boot -a
./otp_build release -a
)
2 Likes

Usually using precompiled OpenSSL linked like static library for mobile development. Already have template CMake project within precompiled OpenSSL that needs to be just linked for iOS/Android. Using OpenSSL 3.5 LTS. Always trying to use LTS version for any kind of application.

1 Like

Where are you getting liberlang.a? Where is it located in release?

1 Like

liberlang.a you will not build directly by the ./otp_build script. You need to build it with xcodebuild in the Mac Terminal.
like mentioned here: otp/HOWTO/INSTALL-IOS.md at master · erlang/otp · GitHub

Linking a binary with your App

To use the resulting libbeam.a it needs to be packaged into a Xcode .xcframework package together with all other required .a files. These include:

  • libbeam.a

  • libz.a

  • libcrypto.a

Basically all .a files that have been generated by the build.

So therefore i build it with the release and call xcodebuild

———-

e.g.

#!/bin/bash
export TARGET_ARCH=‘aarch64-apple-ios’
export BUILD_ARCH=./erts/autoconf/config.guess
export LIBS=find . -not -path "*${BUILD_ARCH}*" -path "*${TARGET_ARCH}*" -not -name "*_st.a" -not -name "*_r.a" -name "*.a" | awk '{ "basename " $1 | getline name; names[name] = $1 } END { for (n in names) { print names[n] }}'

libtool -static -o liberlang.a $LIBS

xcodebuild -create-xcframework -output ./liberlang.xcframework -library liberlang.a

2 Likes

To use liberlang.a no any requirements to wrap it into .xcframework. It’s only more comfortable to use it in Xcode in .cxframework. If you developing C/C++ application for iOS no need to wrap it out. Attach it directly to CMake/make.

Why is libz.a required? By default libz included in iOS. Should it be added additionally?

SUPER-MEGA-HUGE thanks for assistance. You made it clear for me. At least the global direction.

Will try to build it in a few days. The example Qt/QML/C++ application within Erlang going to publish on Github.

Do you know any published C/C++ examples of how to interact with Erlang node from C/C++ application?

1 Like

I think the development environment is the difference to pack all in Xcode in the cxframework + liberlang.a Currently the other details I can’t answer, because I am using Embarcadero RAD Studio (Pascal Code) and therefore it is necessary to add liberlang.a

Got this error when trying to build:

configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
Library search paths:
	/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.1.sdk/usr/lib/
	/usr/lib
Framework search paths:
	/Library/Frameworks/
	/System/Library/Frameworks/
ld: unknown option: -fstack-protector-strong
make[4]: *** [../priv/lib/aarch64-apple-ios/dyntrace.so] Error 1
rm ../priv/obj/aarch64-apple-ios/dyntrace.o
make[3]: *** [opt] Error 2
make[2]: *** [opt] Error 2
make[1]: *** [opt] Error 2
make: *** [libs] Error 2

Do you know what this about?


There were bug when trying to build from main branch of official repository.
All is Ok.

This commands were building for IOS:

$ git checkout maint-27
$ ./otp_build configure --xcomp-conf=xcomp/erl-xcomp-arm64-ios.conf --without-ssl
$ ./otp_build boot -a
$ ./otp_build release -a

The libbeam.a file located here

$ cd bin/aarch64-apple-ios
$ lipo libbeam.a -info
Non-fat file: libbeam.a is architecture: arm64

Inside of RELEASE folder a lot of Erlang beam files. Should it be attached to the iOS application too?

Based on Elixir example mentioned before runtimes/src/test_main.cpp at master · elixir-desktop/runtimes · GitHub there are need to be included “erl_vm.h“ file. Where is this file located?

Found few articles about this topic:

And official documentation:

And one abandoned project:

On the Android side, here is a project showing how to include an Erlang / OTP runtime within an Android project, using the Erlang Jinterface package. It also includes the build mechanism to make the right files executables, which is not trivial on Android:

And to build Erlang for Android, the official instructions are found in the Erlang official repository. Here is a repository where I had stored some build runs a while ago:

Okay :+1: good to know. Because I do not compile from the main branch - only from the tags. e.g. OTP-26.2.5.12