#Issue with OpenSSL when build Window app on Linux

25 messages · Page 1 of 1 (latest)

wet granite
#

Hi everyone, I'm using Linux to build Window Application. It error when build error: failed to run custom build command for openssl-sys v0.9.102``

Detail error:
error: failed to run custom build command for openssl-sys v0.9.102Caused by: process didn't exit successfully:/opt/atlassian/pipelines/agent/build/angular-workspace/src-tauri/target/release/build/openssl-sys-480d1f687a742246/build-script-main(exit status: 101) --- stdout cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_LIB_DIR X86_64_PC_WINDOWS_MSVC_OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=OPENSSL_LIB_DIR OPENSSL_LIB_DIR unset cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_INCLUDE_DIR X86_64_PC_WINDOWS_MSVC_OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR OPENSSL_INCLUDE_DIR unset cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_DIR X86_64_PC_WINDOWS_MSVC_OPENSSL_DIR unset cargo:rerun-if-env-changed=OPENSSL_DIR OPENSSL_DIR unset note: vcpkg did not find openssl: Could not find Vcpkg tree: No vcpkg installation found. Set the VCPKG_ROOT environment variable or run 'vcpkg integrate install' --- stderr thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.102/build/find_normal.rs:190:5: Could not find directory of OpenSSL installation, and this-syscrate cannot proceed without this knowledge. If OpenSSL is installed and this crate had trouble finding it, you can set theOPENSSL_DIRenvironment variable for the compilation process. Make sure you also have the development packages of openssl installed. ... $HOST = x86_64-unknown-linux-gnu $TARGET = x86_64-pc-windows-msvc openssl-sys = 0.9.102

#

I installed apt-get install -y libwebkit2gtk-4.0-dev libappindicator3-dev libgtk-3-dev librsvg2-dev patchelf build-essential pkg-config libssl-dev nsis lld llvm clang

elder lily
#

I'd recommend to just get rid of openssl in favor of rustls if possible. cross-compiling openssl is just pain tbh

wet granite
#

Hmm I still don't understand what you mean, sorry

elder lily
#

Rust has 2 SSL/TLS implementations, a wrapper around the OpenSSL C Library and a rust implementation "rustls".
Pretty much every rust crate that requires the use of such a library have feature flags for you to select which backend you need.
Let's take reqwest (the most common http client library): https://docs.rs/crate/reqwest/latest/features by default it enables the default-tls feature flag which uses native-tls (which is openssl) but if you disable default features, you can also use the rustls-tls feature flags.

Now you basically have to go through all the rust crates you use and check their feature flags (if you sent me your cargo.toml file(s) i can help you).

#

This is what i generally recommend as it's easier than setting up the system dependencies.

The alternative to that would be to add openssl-sys with the vendored feature flag to your project to not have to download openssl yourself. This is still tricky though because it also requires perl etc.

Honestly can't remember if i ever did that (successfully) 🤔

wet granite
#

`[package]
rust-version = "1.59"

[build-dependencies]
tauri-build = { version = "1.3.1", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.6.8", features = [ "updater", "api-all"] }
surrealdb = { version = "1.5.2", features = [
"kv-rocksdb"
] }
rquickjs = "0.6.2"
maplit = "1.0.2"
async-std = { version = "1.12.0", features = ["attributes"] }
once_cell = "1.19.0"
regex = "1.7.3"
zip = "0.6.4"
walkdir = "2.3.3"
reqwest = { version = "0.11.16", features = ["json", "multipart"] }
tokio = { version = "1.38.0", features = ["rt", "macros"] }
futures = "0.3.28"
paho-mqtt = "0.12.5"
whoami = "1.4.0"
config = "0.14.0"
tokio-serial = "5.4.4"
tokio-util = "0.7.11"
serialport = "4.3.0"
fast-float = "0.2.0"
chrono = "0.4.38"
gethostname = "0.4.2"
rust-shared = {path="../../rust-shared", version="0.1.0"}
arc-swap = "1.6.0"
kv = "0.24.0"
changepoint = "0.14.0"
calamine = "0.25.0"
itertools = "0.13.0"
rand = "0.8"
lazy_static = "1.4"
printpdf = "0.7.0"
debounce = "0.2.2"
chrono-tz = "0.9.0"
moka = { version = "0.12.7", features = ["future"] }
bigdecimal = "0.4.3"
derivative = "2.2.0"
dotenv = "0.15.0"
#diesel = { version = "2.1.1", features = ["sqlite", "r2d2"] }
r2d2-diesel = "1.0.0"
diesel_migrations = { version = "2.2.0"}
diesel = { version = "2.2.1", features = ["sqlite", "uuid", "r2d2", "chrono"] }
fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" }
[dev-dependencies]
rstest = "0.21.0"

[features]

by default Tauri runs in production mode

when tauri dev runs it is executed with cargo run --no-default-features if devPath is an URL

default = ["custom-protocol"]

this feature is used for production builds where devPath points to the filesystem

DO NOT remove this

custom-protocol = ["tauri/custom-protocol"]
codec = ["tokio-util/codec"]
`

#

in rust-shared

`[package]
name = "rust-shared"
version = "0.1.0"
edition = "2021"
crate-type = ["rlib", "cdylib"]

See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tauri = { version = "1.2.4", features = ["dialog-all"] }
once_cell = "1.17.1"
regex = "1.7.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.96"
futures = "0.3.28"
tokio-serial = "5.4.1"
tokio-util = "0.7.8"
fast-float = "0.2.0"
maplit = "1.0.2"
serialport = "4.2.0"
chrono = "0.4.24"
surrealdb = { version = "1.0.0-beta.9", features = [
"kv-rocksdb"
] }
reqwest = { version = "0.11.16", features = ["json", "multipart"] }
zip = "0.6.4"
bytes = "1.4.0"
paho-mqtt = { version = "0.12.0", default-features = false, features = ["bundled"] }
async-std = { version = "1.12.0", features = ["attributes"] }
pretty_env_logger = "0.3.1"
tokio = { version = "1.27.0", features = ["rt", "macros"] }
rumqttc = "0.21.0"

[dev-dependencies]
`

#

I build successful with simple app, but fail with my app 😰

#

In README, I have some instruction. But I don't know how to apply in pipeline linux

7. Download OpenSSL and install [here](https://slproweb.com/products/Win32OpenSSL.html) (tested with Win64 OpenSSL v3.1.0) 8. Add OPENSSL_DIR environment variable with value of the location you installed OpenSSL

elder lily
#

yeah, alright. Then the rustls approach is off the table for now x)

#

But i think i got it now.

#

First I downloaded the zip from here https://kb.firedaemon.com/support/solutions/articles/4000121705 and extracted it somewhere easily accessible (in my case the home dir)
Then i set some env vars:

export X86_64_PC_WINDOWS_MSVC_OPENSSL_LIB_DIR="/home/fabianlars/openssl-3/x64/lib/"
export X86_64_PC_WINDOWS_MSVC_OPENSSL_INCLUDE_DIR="/home/fabianlars/openssl-3/x64/include/"
export X86_64_PC_WINDOWS_MSVC_OPENSSL_DIR="/home/fabianlars/openssl-3/x64/"

And then the build command seemed to succeed, at least in a fairly simple app with way less dependencies.

wet granite
#

I will try it soon with the Bitbucket pipeline, hoping it will be the solution. Although right now, I don’t know how to handle it in the pipeline. 🤔

elder lily
#

i mean, setting the env vars should work the same as on linux really, as long as it's in the same step as where you're compiling of course.

That only leaves us with the unzipping of the zip file which i don't know how to do on linux in the command line either

lunar parcel
#

Why not use wsl for local dev ? (Or even build)

#

It should work netter than cross compiling

#

as wsl2 run In a managed linuw VM (even if the kernel is a bit tunned)

#

Hmmm, did I understood wrong ?

elder lily
#

yes

#

we're talking about CI

#

intentionally i assume judging from the other threads

#

but we're also talking about bitbucket which only has linux runners

#

(we want to compile for windows)