search


Running Debian arm Linux on x86 KVM host
Sun May 30 00:00:00 UTC 2021

Download a prebuilt image from debian You will first need to add ssh keys to the image in order ssh into the guest VM sudo account. https://wiki.debian.org/Arm64Qemu



Hello Gambit and Android
Sun May 16 00:00:00 UTC 2021

Install Android NDK

Download commandline tools for your platform.

See https://stackoverflow.com/questions/65262340/cmdline-tools-could-not-determine-sdk-root for why the following convoluted commands are necessary. This might change in the future when google fixes the issue


% unzip commandlinetools-linux-7302050_latest.zip
% mv cmdline-tools tools
% mkdir cmdline-tools 
% mv tools/ cmdline-tools/ 
% mkdir ~/android #replace ~/android with location where you want to store android ndk
% mv cmdline-tools/ ~/android
% sdkmanager "ndk-bundle" "platforms;android-29" "platforms;android-30" "build-tools;29.0.3" "build-tools;30.0.3"

Build Gambit as a static library

You can skip this step by using pre-built binary for android aarch64 libgambit.a

Before we can develop Gambit Scheme apps for Android, the Gambit runtime must be compiled for Arm CPU. There are three ways to do this:

  • Cross compilation to Arm on x86 using Android NDK
  • Compile on Arm emulator using QEMU/KVM on x86
  • Compile on Arm hardware like Raspberry Pi

Compiling Gambit Scheme on arm-linux is no different than compiling on x86-linux so compiling on Raspberry Pi or emulator would not be covered. However here are instructions on Arm Emulation on x86-linux

  • Set environmental variable

    Download ndk-env and change NDK environmental variable to the location of your NDK

    % source ndk-env
  • Build Gambit
    
    % sudo apt-get install build-essential
    % git clone git@github.com:gambit/gambit.git
    % cd gambit
    % ./configure --prefix=/usr/local/gambit-android --host=aarch64 --enable-single-host --enable-multiple-versions --enable-default-runtime-options=f8,-8,t8  --enable-poll
    % make #compile
    % sudo make install #installation directory is configured with --prefix=/usr/local/gambit-android
    

libgambit.a should be in /usr/local/gambit-android/lib

Hello World Android from Gambit Scheme

Now that we have built libgambit.a , we can link C code to it.

  • Compile hello.scm to C
    
    % gsc -c hello.scm
    % gsc -link hello.c
  • Use android toolchain to Compile hello.c hello_c.c
    
    % export GAMBIT=/usr/local/gambit-android
    % $TOOLCHAIN/bin/aarch64-linux-android30-clang -o hello hello.c hello_.c $GAMBIT/lib/libgambit.a -I$GAMBIT/include -L$GAMBIT/lib  -lm -ldl
  • Use adb to push binary to device and execute
    
    % adb push ./hello /data/local/tmp
    % adb shell /data/local/tmp/hello

Socket REPL

One of the most powerful feature of LISP is interactive programming using the REPL. Gambit comes with socket REPL located in examples/web-rep. executed in termux and then telnet to port 7000