Ubuntu doesn’t ship static versions of (all) libraries. Alpine makes a better effort at that, you usually have at least a -static package you can install for this :) So I’d recommend going there (can be just a docker container or chroot) if you want to build static binaries.
Nice that it worked out for you :) The weird segmentation faults you got look like out of memory in codegen phase to me, compiling with --threads=1 can help somewhat there :)
I will try to compile libz.a from the source.
And you are right, having more threads on RPI4 does not speeding up the compilation, so default threads=1 should be sufficient.
ubuntu@ubuntu:~$ sudo apt install zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
zlib1g-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 154 kB of archives.
After this operation, 602 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports focal/main arm64 zlib1g-dev arm64 1:1.2.11.dfsg-2ubuntu1 [154 kB]
Fetched 154 kB in 1s (303 kB/s)
Selecting previously unselected package zlib1g-dev:arm64.
(Reading database ... 109439 files and directories currently installed.)
Preparing to unpack .../zlib1g-dev_1%3a1.2.11.dfsg-2ubuntu1_arm64.deb ...
Unpacking zlib1g-dev:arm64 (1:1.2.11.dfsg-2ubuntu1) ...
Setting up zlib1g-dev:arm64 (1:1.2.11.dfsg-2ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
ubuntu@ubuntu:~$ find /usr/lib -name libz.a
/usr/lib/aarch64-linux-gnu/libz.a
Now I have issue with lib-ssl:
ubuntu@ubuntu:~/Projects/crystal/jhass_crystal$ make spec
Using /usr/bin/llvm-config-10 [version=10.0.0]
CC="cc -fuse-ld=lld" CRYSTAL_CONFIG_LIBRARY_PATH="" CRYSTAL_CONFIG_BUILD_COMMIT="ac2f09b2f" SOURCE_DATE_EPOCH="1593053404" ./bin/crystal build --exclude-warnings spec/std --exclude-warnings spec/compiler -o .build/all_spec spec/all_spec.cr
./bin/crystal: 149: crystal: not found
Using compiled compiler at .build/crystal
bin/crystal: 149: crystal: not found
Using compiled compiler at .build/crystal
GC Warning: Repeated allocation of very large block (appr. size 102400):
May lead to memory leak and poor performance
ld.lld: error: undefined symbol: SSL_library_init
>>> referenced by lib_ssl.cr:242 (/home/ubuntu/Projects/crystal/jhass_crystal/src/openssl/lib_ssl.cr:242)
>>> _main.o:(__crystal_main)
ld.lld: error: undefined symbol: SSL_load_error_strings
>>> referenced by lib_ssl.cr:242 (/home/ubuntu/Projects/crystal/jhass_crystal/src/openssl/lib_ssl.cr:242)
>>> _main.o:(__crystal_main)
I will try that.
I am puzzled though.
I have libssl.a and libcrypto.a installed but it is still cannot link the code.
I think it is due to OpenSSL v1.1.1 installed and Crystal code is using old OpenSSL version v1.0
I will try to downgrade the library if I can or find some compat library to be able to use both.
Ok. Problem was that pkg-config was not installed by default on Ubuntu server 20.04
I installed pkgconf package and it starts to resolve openssl version that is used to identify what method to call in lib_ssl.cr
There’s no generic instructions for raspberry PI, it’s just a hardware platform. The relevant information should be in the installation instructions for the respective operating system / package manager.
I’m not sure which one actually offers binary packages for aarch64. I know only about Alpine Linux’s APK.