Hi Folks,
I have a small rust program using ZeroMQ (libzmq3-dev)
It builds fine on Intel, but I want to deploy this program on ARMv7, so I installed Cross-rs and am trying tor build it with:
cross build --target = "armv7-unknown-linux-gnueabihf"
However it fails to find the static binary:
$ cross build --target armv7-unknown-linux-gnueabihf
Compiling libc v0.2.139
Compiling itoa v1.0.6
Compiling cfg-if v1.0.0
Compiling time-core v0.1.1
Compiling lazy_static v1.5.0
Compiling log v0.4.17
Compiling serde v1.0.163
Compiling num_threads v0.1.6
Compiling serde_json v1.0.96
Compiling ryu v1.0.13
Compiling zmq-sys v0.8.3
Compiling quote v1.0.27
Compiling colored v2.1.0
error: failed to run custom build command forzmq-sys v0.8.3
Caused by:
process didn't exit successfully:/target/debug/build/zmq-sys-06d8fc2643bbdcb1/build-script-build
(exit status: 101)
--- stdout
cargo:rerun-if-env-changed=LIBZMQ_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7-unknown-linux-gnueabihf
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_armv7_unknown_linux_gnueabihf
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_armv7-unknown-linux-gnueabihf
cargo:rerun-if-env-changed=PKG_CONFIG_armv7_unknown_linux_gnueabihf
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=LIBZMQ_STATIC
cargo:rerun-if-env-changed=LIBZMQ_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7-unknown-linux-gnueabihf
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7_unknown_linux_gnueabihf
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7-unknown-linux-gnueabihf
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7_unknown_linux_gnueabihf
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7_unknown_linux_gnueabihf
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR--- stderr
thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zmq-sys-0.8.3/build.rs:31:17:
Unable to locate libzmq:
PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig/:" "pkg-config" "--libs" "--cflags" "libzmq" "libzmq >= 3.2"
did not exit successfully: exit status: 1
error: could not find system library 'libzmq' required by the 'zmq-sys' crate--- stderr
Package libzmq was not found in the pkg-config search path.
Perhaps you should add the directory containinglibzmq.pc' to the PKG_CONFIG_PATH environment variable No package 'libzmq' found Package libzmq was not found in the pkg-config search path. Perhaps you should add the directory containing
libzmq.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libzmq' foundnote: run with
RUST_BACKTRACE=1
environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Looking at the cross-rs notes, it mentions and option to specify pre-build steps which I could use (here), so I tried adding this to my .cargo/config.toml
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes libzmq3-dev:$CROSS_DEB_ARCH"
]
The error is:
error: expected a table, but found a array for
target.armv7-unknown-linux-gnueabihf.pre-build
in .cargo/config.toml
Any tips on how to get it cross-compiling with ZeroMQ ?