如何解决如何在 C++ 中使用 bazel 构建 Google tink 库?
我想为我的应用使用 Google tink
库。我使用 android ndk
绑定了我的代码。但是,我无法使用 tink
构建 Google bazel
库。我已经在 github (https://github.com/google/tink) 上尝试过他们的例子。此外,我对 bazel
没有任何经验。因此,如果有人知道如何以任何方式构建 Google tink
库,我也愿意接受这些选择。
我正在使用:
- Ubuntu 20.04
- 巴泽尔 3.1.0
- gcc 版本是 9.3.0
我曾尝试关注https://github.com/google/tink/blob/master/examples/cc/helloworld/README.md,但结果出现错误:
bazel build ...
Starting local Bazel server and connecting to it...
ERROR: error loading package 'javascript/aead/internal': Unable to find package for @npm//@bazel/typescript:index.bzl: The repository '@npm' could not be resolved.
INFO: Elapsed time: 6.455s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded)
currently loading: javascript/binary ... (6 packages)
解决方法
编写 README.md
时,整个项目都在一个 Bazel workspace 中。现在,examples
子目录是它自己的独立工作区,因此您需要在执行 cd
之前bazel
进入它。
正确的说明:
# Build the code.
git clone https://github.com/google/tink
cd tink/examples/cc
bazel build ...
# Create some input.
echo "some plaintext" > foo.txt
# Encrypt.
./bazel-bin/helloworld/hello_world ./helloworld/aes128_gcm_test_keyset_json.txt \
encrypt foo.txt "some aad" foo.encrypted
# Decrypt.
./bazel-bin/helloworld/hello_world ./helloworld/aes128_gcm_test_keyset_json.txt \
decrypt foo.encrypted "some aad" foo-decrypted.txt
# Inspect the output.
cat foo-decrypted.txt
请注意,the C++ implementation also supports using CMake,它可能更容易满足您的目的。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。