Sod Almighty
Sod Almighty

Reputation: 1786

How to statically link a Chicken Scheme program that uses extensions?

I have need to compile and statically link a Chicken program. I expect to use many extensions, most notably http-client.

I can compile the source with the following command:

csc -compile-syntax -static linux-setup.scm

or

csc -R http-client -compile-syntax -static linux-setup.scm

But when I run it, I get the following error:

Error: (require) cannot load extension: http-client

    Call history:

    ##sys#require           <--

I have also tried (declare (uses http-client)) in the source, with no success:

linux-setup.o: In function `f_369':
/mnt/data/Documents/Programming/chicken-scheme/linux-setup/linux-setup.c:219:
 undefined reference to `C_http_2dclient_toplevel'
collect2: error: ld returned 1 exit status

Error: shell command terminated with non-zero exit status 256: 'gcc' 'linux-setup.o'
 -o 'linux-setup' -L"/usr/lib"  -Wl,-R"/usr/lib" -static '/usr/lib/libchicken.a' -lm -ldl

Static linking is something I need. This is not an XY problem. I need my executables to run on a freshly-installed Linux system with no dependancies. This is the primary reason I switched from Common Lisp to Scheme in the first place.

What am I doing wrong, please?

Upvotes: 3

Views: 1379

Answers (1)

dercz
dercz

Reputation: 962

Assuming your program is in a-program.scm file:

csc -deploy a-program.scm
cd a-program/
chicken-install -deploy -p $PWD http-client

...et voilà!

edit: turns out that the proper answer to the problem posted is solved in this document: http://www.foldling.org/scheme.html#compiling-statically-linked-chicken-scheme-programs-with-extensions

Upvotes: 1

Related Questions