Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-compiling issue with libcrypto on Linux #674

Closed
hedgar2017 opened this issue Sep 7, 2020 · 4 comments
Closed

Cross-compiling issue with libcrypto on Linux #674

hedgar2017 opened this issue Sep 7, 2020 · 4 comments

Comments

@hedgar2017
Copy link

hedgar2017 commented Sep 7, 2020

I have an Ubuntu Docker image which cross-compiles my application for MacOS.
I use osxcross tools and the OpenSSL 1.1.1g build.
All the crates which depend on openssl-sys are built without errors, but I have an issue with sqlx-macros, which requires some libcrypto symbols, and for some reason rustc is unable to find the library.

   Compiling sqlx v0.4.0-beta.1
     Running `rustc --crate-name sqlx --edition=2018 /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-0.4.0-beta.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -Cembed-bitcode=no --cfg 'feature="json"' --cfg 'feature="macros"' --cfg 'feature="postgres"' --cfg 'feature="runtime-async-std"' --cfg 'feature="sqlx-macros"' -C metadata=7c40358ea7c4ec8a -C extra-filename=-7c40358ea7c4ec8a --out-dir /zinc-dev/target/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -C linker=x86_64-apple-darwin14-clang -L dependency=/zinc-dev/target/x86_64-apple-darwin/release/deps -L dependency=/zinc-dev/target/release/deps --extern sqlx_core=/zinc-dev/target/x86_64-apple-darwin/release/deps/libsqlx_core-97f61aca60bd39af.rmeta --extern sqlx_macros=/zinc-dev/target/release/deps/libsqlx_macros-e396e661b598d675.so --cap-lints allow -L '/zinc-dev/[email protected]/1.1.1g/lib/' -C link-args=-lssl -C link-args=-lcrypto`
error: /zinc-dev/target/release/deps/libsqlx_macros-e396e661b598d675.so: undefined symbol: PKCS5_PBKDF2_HMAC
  --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-0.4.0-beta.1/src/lib.rs:59:1
   |
59 | pub extern crate sqlx_macros;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: could not compile `sqlx`.

Could you please give a hint?

@hedgar2017
Copy link
Author

hedgar2017 commented Sep 7, 2020

I tried to specify linker flags in different manners, but with no effect:
-L '/zinc-dev/[email protected]/1.1.1g/lib/' -C link-args=-lssl -C link-args=-lcrypto
-L '/zinc-dev/[email protected]/1.1.1g/lib/' -lssl -lcrypto

.cargo/config:

[target.x86_64-apple-darwin]
linker = "x86_64-apple-darwin14-clang"
ar = "x86_64-apple-darwin14-ar"
rustflags = [
    "-L", "/zinc-dev/[email protected]/1.1.1g/lib",
    "-C", "link-args=-lssl",
    "-C", "link-args=-lcrypto",
]

@emk
Copy link

emk commented Sep 8, 2020

I am not associated with sqlx in any way, but I've recently managed to get this working for musl-libc targets using my Docker image https://github.com/emk/rust-musl-builder. I am happy to support this use case and help improve the documentation.

For a discussion of the various fixes and workarounds people have used, see #670.

@hedgar2017
Copy link
Author

@emk , thank you very much!
It seems unrelated to my specific MacOS cross-compiling case, but I have found some other potentially viable solutions there.

@hedgar2017
Copy link
Author

hedgar2017 commented Sep 8, 2020

@emk , thanks one more time!
Adding

[dependencies.openssl]
version = "0.10"
features = [
    "vendored"
]

to Cargo.toml of the application depending on sqlx-macros worked like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants