如何为Android构建openssl-sys?

huangapple go评论91阅读模式
英文:

How to build openssl-sys for android?

问题

我编写了一个使用git2库的程序,在我的本地机器上编译通过(Macbook M2,使用brew安装了openssl),但当我尝试为Android编译该程序时,出现了一个错误:“错误:无法为'openssl-sys v0.9.90'运行自定义构建命令”。

我尝试了为Android构建openssl,但不知道如何构建它,而且也有过时的教程。

我尝试将openssl添加到PATH,但没有帮助。
此外,我尝试在docker(ubuntu)中构建它,但仍然无法构建openssl。

英文:

I wrote a program that uses the git2 library and it compiled fine on my local machine (Macbook M2,openssl installed using brew), but when I tried to compile the program for Android, it gave me an "error: failed to run custom build command for 'openssl-sys v0.9.90'"

I tried to build openssl for android, but i don't know how to build it and there are also outdated tutorials

I tried adding openssl to PATH but to no help
Also I tried to build it in docker(ubuntu),but it still cannot build openssl.

答案1

得分: 1

我使用了来自 crate 的 OpenSSL,它会自动编译平台特定并且静态链接的 OpenSSL 版本。我不知道我是否正确,我只是一个初学者。但它确实解决了问题。

[dependencies]
openssl = { version = "*", features = ["vendored"] }

在你的 Cargo.toml 中添加。

英文:

I used openssl from crate, which automatically compiles a platform-specific and statically linked version of openssl. I don't know if I'm right, I'm just a beginner
But it does solve the problem

[dependencies]
openssl = { version = "*", features = ["vendored"] }

Add in your Cargo.toml

huangapple
  • 本文由 发表于 2023年8月5日 12:39:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76840152.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定