I´m trying to cross compile my code on a Ubuntu 18.04 x86_64 (x86_64-unknown-linux-gnu) host to a target armhf (armv7-unknown-linux-gnueabihf).
My project depends on openssl-sys.
I have libssl-dev and pkg-config installed so I can build it for the host arch (x86_64). I was also able to build it to the target arch (armhf) before I added some crate that depends on openssl.
Now I can´t cross compile it anymore to armhf, because I´m missing the openssl dependency in the required arch:
duli@uvm:/mnt/homes/duli/projects/iwatcher/rust/iwatcher$ RUSTFLAGS="-C linker=arm-linux-gnueabihf-gcc" cargo build --target "armv7-unknown-linux-gnueabihf" && scp target/armv7-unknown-linux-gnueabihf/debug/iwatcher email@example.com:/home/orangepi Compiling openssl-sys v0.9.55 Compiling email v0.0.20 Compiling log v0.4.8 Compiling encoding v0.2.33 Compiling memchr v2.3.3 error: failed to run custom build command for `openssl-sys v0.9.55` Caused by: process didn't exit successfully: `/mnt/homes/duli/projects/iwatcher/rust/iwatcher/target/debug/build/openssl-sys-a2c3f9a058658564/build-script-main` (exit code: 101) --- stdout cargo:rustc-cfg=const_fn cargo:rerun-if-env-changed=ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_LIB_DIR ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=OPENSSL_LIB_DIR OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_INCLUDE_DIR ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_DIR ARMV7_UNKNOWN_LINUX_GNUEABIHF_OPENSSL_DIR unset cargo:rerun-if-env-changed=OPENSSL_DIR OPENSSL_DIR unset run pkg_config fail: "Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override" --- stderr thread 'main' panicked at ' Could not find directory of OpenSSL installation, and this `-sys` crate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it, you can set the `OPENSSL_DIR` environment variable for the compilation process. Make sure you also have the development packages of openssl installed. For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora. If you're in a situation where you think the directory *should* be found automatically, please open a bug at https://github.com/sfackler/rust-openssl and include information about your system as well as this message. $HOST = x86_64-unknown-linux-gnu $TARGET = armv7-unknown-linux-gnueabihf openssl-sys = 0.9.55 ', /home/duli/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.55/build/find_normal.rs:155:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... error: build failed
I guess the relevant part is this:
Could not find directory of OpenSSL installation, and this
proceed without this knowledge. If OpenSSL is installed and this crate had
trouble finding it, you can set the
OPENSSL_DIRenvironment variable for the
My project´s dependencies are:
confy = "~0.4.0"
pwr-hd44780 = "~0.1.3"
clap = "~2.33.0"
sysfs_gpio = "~0.5.4"
unicode-segmentation = "~1.6.0"
serde = "~1.0.106"
serde_derive = "~1.0.106"
natpmp = "~0.2.0"
parse_int = "~0.4.0"
chrono = "~0.4.11"
lettre = "0.9"
lettre_email = "0.9"
I´m really new to cross compiling so I have no clue as how to proper install the required armhf package in Ubuntu neither how to point the compiler to the proper environment paths.
Any help would be appreciated!
Thanks a lot!