[Top][All Lists]

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

[Chicken-users] Having trouble statically compiling code

From: stugol
Subject: [Chicken-users] Having trouble statically compiling code
Date: Sun, 21 Aug 2016 01:13:40 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

Hi everyone,

I have the need to statically compile my code into a single executable with no dependencies. To this end, I have written a program in Chicken, which will enumerate all dependencies - that is, eggs and other source files - of a Chicken code file and statically compile them into an executable. The lookup-table egg was a pain, and I had to hard-code a workaround, but the other eggs seem to work.

I have attached a copy of my project. To use it, simply unzip to a suitable directory and run it as follows:

./static-compile.scm ./test-source.scm

Having compiled all eggs into object files, it then runs the command:

csc -d2 -O0 -static -uses http-client -uses intarweb -uses defstruct -uses uri-common -uses uri-generic -uses matchable -uses base64 -uses message-digest -uses setup-helper -uses miscmacros -uses check-errors -uses variable-item -uses blob-utils -uses string-utils -uses lookup-table -uses record-variants -uses synch -uses md5 -uses sendfile /mnt/data/Documents/Programming/chicken-scheme/static-compile/./test-source.scm defstruct.o uri-generic.o matchable.o uri-common.o base64.o intarweb.o setup-helper.o miscmacros.o check-errors.o variable-item.o record-variants.o synch.o lookup-table.o string-utils.o blob-utils+blob-set-int.o blob-utils.o message-digest.o md5.o sendfile.o http-client.o -o /mnt/data/Documents/Programming/chicken-scheme/static-compile/./test-source

This complains about multiple definitions of C_blob_2dutils_toplevel, which I assume is because I am compiling blob-hexadecimal.scm and blob-set-int.scm separately into object files. Perhaps I should not be doing that. But that's a minor issue. If I remove one of the object files from the final compile stage, it then compiles. You can replicate this yourself by interrogating the generated logfile.log for the /tmp/xxxxx directory, going there, then issuing the revised csc call.

However, when I run the resultant executable, I get an error about a missing intarweb extension. Which is strange, because if you look carefully at the command line above, you can see I'm both linking with its object file and referencing it with a uses declaration.

What am I doing wrong, please?

Incidentally, is there any way to instruct csc to use musl instead of libc? I'm told that this would eliminate any dependency on a specific version of libc on the target machine. I gather the musl project is a bit lacking in header files, however.

    Sod Almighty

Description: Zip archive

reply via email to

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