Statically compiling with additional eggs in Chicken 5

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Statically compiling with additional eggs in Chicken 5

Jeff Moon
I'm using chicken 5.0.0.  I've used it to create a handful of apps that I have distributed as static binaries, and it seems to be working very well.  However, when I try to include certain eggs, the static builds do not seem to work.  I'm wondering if anybody has gotten static compiles to work with any of the following eggs: postgresql, sqlite3, or sql-de-lite?

If I have the following:
(import regex)
(print "Hello world")
And then run:
csc -static test.scm
It runs fine. 

If I have:
(import regex sqlite3)
(print "Hello world")
And run the same csc line, I get:

/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3063':
sql-de-lite.static.c:(.text+0x5bdb): undefined reference to `sqlite3_version'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6833':
sql-de-lite.static.c:(.text+0x8c96): undefined reference to `sqlite3_bind_parameter_name'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3664':
sql-de-lite.static.c:(.text+0x8dcd): undefined reference to `sqlite3_column_name'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_7306':
sql-de-lite.static.c:(.text+0x1431f): undefined reference to `sqlite3_column_blob'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `stub2669.isra.16':
sql-de-lite.static.c:(.text+0x19efa): undefined reference to `sqlite3_aggregate_context'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `stub2621.isra.17':
sql-de-lite.static.c:(.text+0x19ffc): undefined reference to `sqlite3_aggregate_context'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3831':
sql-de-lite.static.c:(.text+0x1a435): undefined reference to `sqlite3_result_error'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_8632':
sql-de-lite.static.c:(.text+0x1a74f): undefined reference to `sqlite3_result_null'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `stub558.isra.14':
sql-de-lite.static.c:(.text+0x1a7fc): undefined reference to `sqlite3_result_double'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `stub272':
sql-de-lite.static.c:(.text+0x1ab66): undefined reference to `sqlite3_bind_blob'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6739':
sql-de-lite.static.c:(.text+0x1ae89): undefined reference to `sqlite3_bind_null'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6632':
sql-de-lite.static.c:(.text+0x1b07a): undefined reference to `sqlite3_bind_parameter_index'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3731':
sql-de-lite.static.c:(.text+0x1b276): undefined reference to `sqlite3_create_function_v2'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `stub476':
sql-de-lite.static.c:(.text+0x1bccb): undefined reference to `sqlite3_busy_handler'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3649':
sql-de-lite.static.c:(.text+0x1c090): undefined reference to `sqlite3_column_type'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_7261':
sql-de-lite.static.c:(.text+0x1c1e0): undefined reference to `sqlite3_column_int64'
sql-de-lite.static.c:(.text+0x1c27e): undefined reference to `sqlite3_column_double'
sql-de-lite.static.c:(.text+0x1c32c): undefined reference to `sqlite3_column_text'
sql-de-lite.static.c:(.text+0x1c46d): undefined reference to `sqlite3_column_bytes'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `stub346':
sql-de-lite.static.c:(.text+0x1c6e3): undefined reference to `sqlite3_bind_text'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `stub171':
sql-de-lite.static.c:(.text+0x1c81b): undefined reference to `sqlite3_step'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `stub132.constprop.23':
sql-de-lite.static.c:(.text+0x1c8a0): undefined reference to `sqlite3_prepare_v2'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `stub629.isra.13':
sql-de-lite.static.c:(.text+0x1cb56): undefined reference to `sqlite3_result_int64'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6689':
sql-de-lite.static.c:(.text+0x1ce2f): undefined reference to `sqlite3_bind_int64'
sql-de-lite.static.c:(.text+0x1ceb4): undefined reference to `sqlite3_bind_double'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_8076':
sql-de-lite.static.c:(.text+0x1cfee): undefined reference to `sqlite3_get_autocommit'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3840':
sql-de-lite.static.c:(.text+0x1d7f9): undefined reference to `sqlite3_result_error'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_7696':
sql-de-lite.static.c:(.text+0x1dc30): undefined reference to `sqlite3_close'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6896':
sql-de-lite.static.c:(.text+0x1dd15): undefined reference to `sqlite3_last_insert_rowid'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6875':
sql-de-lite.static.c:(.text+0x1df2f): undefined reference to `sqlite3_total_changes'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6854':
sql-de-lite.static.c:(.text+0x1e149): undefined reference to `sqlite3_changes'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6430':
sql-de-lite.static.c:(.text+0x1e472): undefined reference to `sqlite3_reset'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_7853':
sql-de-lite.static.c:(.text+0x1e55c): undefined reference to `sqlite3_errmsg'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_7832':
sql-de-lite.static.c:(.text+0x1e95f): undefined reference to `sqlite3_errcode'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_8414':
sql-de-lite.static.c:(.text+0x1ed47): undefined reference to `sqlite3_value_blob'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6954':
sql-de-lite.static.c:(.text+0x1ee2c): undefined reference to `sqlite3_column_count'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3348':
sql-de-lite.static.c:(.text+0x1eef9): undefined reference to `sqlite3_bind_parameter_index'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_4230':
sql-de-lite.static.c:(.text+0x1ef8d): undefined reference to `sqlite3_user_data'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_9122':
sql-de-lite.static.c:(.text+0x1f1ca): undefined reference to `sqlite3_result_null'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3122':
sql-de-lite.static.c:(.text+0x1f300): undefined reference to `sqlite3_open'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3963':
sql-de-lite.static.c:(.text+0x1f5bf): undefined reference to `sqlite3_result_text'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3788':
sql-de-lite.static.c:(.text+0x1fbcf): undefined reference to `sqlite3_result_blob'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_5903':
sql-de-lite.static.c:(.text+0x1feaa): undefined reference to `sqlite3_bind_parameter_count'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_3229':
sql-de-lite.static.c:(.text+0x20199): undefined reference to `sqlite3_step'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_6271':
sql-de-lite.static.c:(.text+0x2029a): undefined reference to `sqlite3_finalize'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_8372':
sql-de-lite.static.c:(.text+0x20828): undefined reference to `sqlite3_value_int64'
sql-de-lite.static.c:(.text+0x2089b): undefined reference to `sqlite3_value_double'
sql-de-lite.static.c:(.text+0x2091d): undefined reference to `sqlite3_value_text'
sql-de-lite.static.c:(.text+0x20a26): undefined reference to `sqlite3_value_bytes'
/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o: In function `f_8345':
sql-de-lite.static.c:(.text+0x20c97): undefined reference to `sqlite3_value_type'
collect2: error: ld returned 1 exit status

Error: shell command terminated with non-zero exit status 256: 'gcc' 'test.o' '/path/chicken/5.0.0/lib/chicken/9/regex.o' '/path/chicken/5.0.0/lib/chicken/9/sql-de-lite.o' '/path/chicken/5.0.0/lib/chicken/9/srfi-18.o' '/path/chicken/5.0.0/lib/chicken/9/object-evict.o' '/path/chicken/5.0.0/lib/chicken/9/foreigners.o' '/path/chicken/5.0.0/lib/chicken/9/sql-de-lite-cache.o' '/path/chicken/5.0.0/lib/chicken/9/srfi-69.o' '/path/chicken/5.0.0/lib/chicken/9/matchable.o' -o 'test' -L/path/chicken/5.0.0/lib -Wl,-R/path/chicken/5.0.0/lib /path/chicken/5.0.0/lib/libchicken.a -lm -ldl

If anybody has any experience with getting static compiles like this to work, I would really appreciate it.
Jeff


_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users
Reply | Threaded
Open this post in threaded view
|

Re: Statically compiling with additional eggs in Chicken 5

Vasilij Schneidermann-2
Hey Jeff,

> I'm wondering if anybody has gotten static compiles to work with any
> of the following eggs: postgresql, sqlite3, or sql-de-lite?

The difference between these eggs and everything else are foreign
dependencies they link against.  Normally you'd link against a shared
library provided by your OS, however for static linking you'd need to
have a statically linked version of that library around.  The details
depend on your OS, on Arch Linux for instance one can set the
`staticlibs` option in a PKGBUILD to not strip static libraries obtained
from the build (which means that the build should produce one, the
details of which depend very much on the package and its build system).

Alternatively, if the library they link against is small enough to be
shipped with the egg, the bundled sources could be compiled instead.
The sql-de-lite egg *should* support this mode of operation, I didn't
test it though when porting it.

> [...]
> collect2: error: ld returned 1 exit status

Note how this fails at the linking stage.  In other words, no suitable
version of the library providing the symbols has been found.

Vasilij

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Statically compiling with additional eggs in Chicken 5

Peter Bex
In reply to this post by Jeff Moon
On Tue, May 07, 2019 at 01:06:09PM -0700, Jeff Moon wrote:
> I'm using chicken 5.0.0.  I've used it to create a handful of apps that I
> have distributed as static binaries, and it seems to be working very well.
> However, when I try to include certain eggs, the static builds do not seem
> to work.  I'm wondering if anybody has gotten static compiles to work with
> any of the following eggs: postgresql, sqlite3, or sql-de-lite?

Hi Jeff,

To get the correct linking options for linking in the libraries you can
use something like:

$ pkg-config --static --libs sqlite3
-lsqlite3 -lm -ldl -lpthread

Then, you can link the program:

$ csc -static -L -lsqlite3 -L -lm -L -ldl -L -lpthread test.scm

You'll note that the libraries are still linked dynamically (with `ldd`).
To make it fully static, use -L -static:

$ csc -static -L -static -L -lsqlite3 -L -lm -L -ldl -L -lpthread test.scm

For PostgreSQL, I used pkg-config --static --libs pq, but this told me
to use -lgssapi_krb5 and there is no static version of that library in
Debian at least.  So I think you can't link it statically on Debian.

Cheers,
Peter

_______________________________________________
Chicken-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/chicken-users

signature.asc (499 bytes) Download Attachment