[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] compile .scm for android

From: Jin Cao
Subject: Re: [Chicken-users] compile .scm for android
Date: Thu, 31 Mar 2016 23:34:20 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0

Hi Rafeal,
Sorry for late reply. Your Makefile is useful. I managed to compile .scm for android, but I am stuck in another problem:

As ndk provided an interface for java, code written in c would be a normal function be called by java jni.
Something like:

/* jni code which calls the function fact compiled from fact.scm code in shared library */
func(int i)
    return fact(i) + 1;

;; fact.scm
(define (facts n)
  (if (= n 0)
      (* n (facts (- n 1)))))
(define-external (fact (int n)) int
  (display "fact is called\n")
  (facts n))

When the func is invoked once, this works fine. But 'Segmentation fault' will be encountered if func is invoked more than once. Note that CHICKEN_run() is executed in func(), but not main() as in c.

My question is that can compiled scheme procedure be invoked as normal function?

It seems that the compiled procedure need the runtime chicken environment, and CHICKEN_run() must execute once.

Are these possible?
1. run compiled scheme without chicken runtime, or
2. let CHICKEN_run() be executed in the "right way"

Since I am new to both chicken and android, if I miss something or do not well understand the mechanism of chicken, please let me know.

Any suggestion would be appreciated.


On 03/08/2016 06:57 AM, F. Rafael Leon wrote:
I attach a Makefile for Android, building on Linux with NDK.

ndk-build must be on the path. It auto-detects almost everything else.

It builds from sharedlib.scm.

Inside of sharedlib.scm, include a.scm, b.scm, c.scm as dependencies:

(include "a.scm")
(include "b.scm")
(include "c.scm")

You will need to edit the CHICKEN_INC and CHICKEN_LIB paths to your
pre-built Android chicken.h and Android

I was expecting this question to appear on the mailing list.


Chicken-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]