static linking - How can I produce a Crystal executable with no dependencies? -


i'm writing program in crystal, intend compile , move other systems execution. ideally, should have no dependencies, target systems fresh installations of linux.

sadly, can't around libc dependency, presumably have compile executable on system possessing lowest version of libc wish target. figure should forward-compatible.

i'm having difficulty libssl, however. default installations of debian wheezy don't seem come libssl, error when running executable:

error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: no such file or directory 

i assume dependency exists because require "http/client" in source. however, make no ssl-related calls, use connect unsecured websites.

i apparently have dependency on libevent-2.0.so.5. presumably crystal programs do. knows how many other dependencies crystal has?

my executables have run on freshly-installed linux system. so, how can produce crystal executable no dependencies? other libc, suppose.

in linux, can list shared libraries executable needs using ldd command. in osx, otool -l used same purpose.

normally, linker use shared libraries while building executable if can find them. so, need do, force linker use static libraries instead. (in future might add flag compiler force choice)

you should find of these static libraries in /opt/crystal/embedded/lib. use these generate portable crystal compiler.

in order use these libraries can run:

$ library_path=/opt/crystal/embedded/lib crystal build my_app.cr 

that should privilege libraries available in directory before considering others installed in standard locations.

unfortunately, openssl not distributed crystal, must either copy or build static version of libssl , libcrypto. it's common library anyway, available in linux distribution.

regarding libc, that's more tricky. compile crystal binary releases using old centos , debian distributions make compatible many more libc versions.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -