[gambit-list] compiling for arm android on linux

Sonny To son.c.to at gmail.com
Sun May 9 15:57:58 EDT 2021


How to compile a simple hello world program on x86 to arm for android?

--- hello.scm ---
(define wassup (lambda ()
   (display "hello from scheme\n")))

(wassup)
---end hello.scm---


% gsc -exe -target arm hello.scm
% adb push ./hello /data/local/tmp
% adb shell /data/local/tmp/hello

/system/bin/sh: /data/local/tmp/hello: not executable: 64-bit ELF file

% file hello
hello: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2,
BuildID[sha1]=64cb09b1432959e8f4f9734d72e99580f6091497, for GNU/Linux
3.2.0, with debug_info, not stripped

This doesn't like the -target option is generating an ARM binary.

I tried to take a different route by generating C code like this but I
can't even compile the generated C code on linux x86:

% gsc -c hello.scm
% gcc hello.c $GAMBIT_HOME/lib/libgambit.a
$GAMBIT_HOME/lib//libgambitgsc.a $GAMBIT_HOME/lib/libgambitgsi.a
-I$GAMBIT_HOME/include -lm
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o:
in function `_start':
(.text+0x24): undefined reference to `main'
/usr/bin/ld: /tmp/ccWylAo9.o: in function `___H_hello_23_':
hello.c:(.text+0xb4): undefined reference to `___G_wassup'
/usr/bin/ld: hello.c:(.text+0x108): undefined reference to
`___G_wassup'
/usr/bin/ld: hello.c:(.text+0x186): undefined reference to
`___G_wassup'
/usr/bin/ld: /tmp/ccWylAo9.o: in function `___setup_mod':
hello.c:(.text+0x3d4): undefined reference to `___G_hello_23_'
/usr/bin/ld: /tmp/ccWylAo9.o: in function `___init_mod':
hello.c:(.text+0x400): undefined reference to `___G_hello_23_'
/usr/bin/ld: /tmp/ccWylAo9.o: in function `___LNK_hello':
hello.c:(.text+0x41a): undefined reference to `___S_hello'
/usr/bin/ld: hello.c:(.text+0x428): undefined reference to
`___S_hello_23_'
/usr/bin/ld: /usr/local/gambit/lib/libgambit.a(os_dyn.o): in function
`___dynamic_load':
os_dyn.c:(.text+0x1b0): undefined reference to `dlopen'
/usr/bin/ld: os_dyn.c:(.text+0x1c8): undefined reference to `dlsym'
/usr/bin/ld: os_dyn.c:(.text+0x2d9): undefined reference to `dlerror'
/usr/bin/ld: os_dyn.c:(.text+0x305): undefined reference to `dlclose'
/usr/bin/ld: /usr/local/gambit/lib/libgambit.a(os_dyn.o): in function
`___cleanup_dyn_module':
os_dyn.c:(.text+0x4db): undefined reference to `dlclose'
/usr/bin/ld: /usr/local/gambit/lib/libgambit.a(os_io.o): in function
`___device_stream_setup_from_process':
os_io.c:(.text+0x3592): undefined reference to `openpty'
collect2: error: ld returned 1 exit status


How do I compile the generated C code?

Thanks for any help



More information about the Gambit-list mailing list