[英]Compile OpenSSL for Android with Bazel
I'm building a native library for my Android application with bazel. 我正在使用bazel为我的Android应用程序构建一个本机库。
I'd like to use some OpenSSL functions on it like this: 我想在它上面使用一些OpenSSL函数,如下所示:
#include <jni.h>
#include <openssl/aes.h>
...
AES_encrypt(in, out, key);
How to add the openssl library to bazel build ? 如何将openssl库添加到bazel构建?
Subsidiary question : which archive I should use ? 附属问题 :我应该使用哪个档案?
openssl-1.1.0c.tar.gz
openssl-1.0.2j.tar.gz
openssl-1.0.1u.tar.gz
openssl-fips-2.0.13.tar.gz
openssl-fips-ecp-2.0.13.tar.gz
I've downloaded the openssl-1.0.2j
archive. 我已经下载了openssl-1.0.2j
存档。 and added a cc_library
entry to my BUILD
file. 并在我的BUILD
文件中添加了cc_library
条目。
cc_library(
name = "openssl",
srcs = glob([
"openssl-1.0.2j/crypto/**/*.h",
"openssl-1.0.2j/crypto/**/*.c"
]),
includes = [
"openssl-1.0.2j",
"openssl-1.0.2j/crypto/",
],
visibility = ["//visibility:public"],
)
I've this error: 我有这个错误:
openssl-1.0.2j/crypto/dh/p512.c:60:24: fatal error: openssl/bn.h: No such file or directory
#include <openssl/bn.h>
But I don't understand why this code is trying to include a file from openssl
while it's in openssl-1.0.2j/crypto/
但我不明白为什么这段代码试图在openssl-1.0.2j/crypto/
包含openssl
的文件
With openssl-1.1.0c
使用openssl-1.1.0c
openssl-1.1.0c/include/openssl/e_os2.h:13:34: fatal error: openssl/opensslconf.h: No such file or directory
# include <openssl/opensslconf.h>
Even if I run the Configure
command, no opensslconf.h
file is generated. 即使我运行Configure
命令,也不会生成opensslconf.h
文件。
Based on @Ulf Adams' answer, I gave up trying to compile OpenSSL
with bazel. 基于@Ulf Adams的回答,我放弃了尝试用bazel编译OpenSSL
。 I used BoringSSL
instead. 我用的是BoringSSL
。
BoringSSL
is a fork of OpenSSL, and can easily be incorporated to a bazel project by doing: BoringSSL
是OpenSSL的一个分支,可以通过以下方式轻松地合并到bazel项目中:
git_repository(
name = "boringssl",
commit = "_some commit_",
remote = "https://boringssl.googlesource.com/boringssl",
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.