cannot find crti.o: No such file or directory
:
I donāt recall now, but it might have been solved by apk add musl-dev
for me a while back.
This is my current rustc version:
rustc 1.76.0 (07dca489a 2024-02-04)
The issue was reproducible here on 3.19 version off Alpine LXC for me.
/usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lbz2: No such file or directory
For the above error message, compiling the entire safe_network
repo with the extra RUSTFLAGS (see below) seems to make safenode-manager
work without the linker error:
export RUSTFLAGS="-Ctarget-feature=-crt-static"
Since Rust 1.72+, seems they added:
- [Force all native libraries to be statically linked when linking a static binary]([rust-lang/rust#111698](https://github.com/rust-lang/rust/pull/111698))
It seems the extra flags above would force a dynamic binary with dynamic libs, which may not be intended here, but seems to get me past the linker error for now on Alpine 3.19 LXC.
safe-build-122:/.../safe_github/safe_network/target/release# ./safenode-manager --help
A command-line application for installing, managing and operating `safenode` as a service.
Usage: safenode-manager [OPTIONS] <COMMAND>
Commands:
add Add one or more new safenode services
faucet Run a faucet server for use with a local network
kill Kill the running local network
join Join an existing local network
remove Remove a safenode service
run Run a local network
start Start a safenode service
status Get the status of services
stop Stop a safenode service
upgrade Upgrade safenode services
help Print this message or the help of the given subcommand(s)
Options:
-v, --verbose...
-h, --help Print help
-V, --version Print version
FWIW, below were the size difference off the binaries with and without that flag:
Before:
-rwxr-xr-x 1 x x 33945840 Feb 24 02:29 safe
-rwxr-xr-x 1 x x 26805840 Feb 24 02:29 safenode
-rwxr-xr-x 1 x x 27125920 Feb 24 02:29 safenode_rpc_client
Note: safenode-manager
couldnāt be built originally.
After setting the above RUSTFLAGS:
-rwxr-xr-x 2 x x 33581352 Feb 27 20:47 safe
-rwxr-xr-x 2 x x 26433064 Feb 27 20:46 safenode
-rwxr-xr-x 2 x x 26778832 Feb 27 20:47 safenode_rpc_client
-rwxr-xr-x 2 x x 19656296 Feb 27 20:44 safenode-manager
However, safenode-manager
even after compiling still complains about the following when using the add
arg:
Error loading shared library libbz2.so.1: No such file or directory (needed by ./safenode-manager)
Error relocating ./safenode-manager: BZ2_bzDecompress: symbol not found
Error relocating ./safenode-manager: BZ2_bzDecompressEnd: symbol not found
Error relocating ./safenode-manager: BZ2_bzDecompressInit: symbol not found
Running apk add libbz2
on this new LXC fixed the above on the newly compiled binary!