如何在 C++ 中使用 bazel 构建 Google tink 库?

索伦

我想tink为我的应用程序使用 Google库。我使用 android 绑定了我的代码ndk但是,我无法tink使用bazel. 我已经在 github ( https://github.com/google/tink )上尝试过他们的例子此外,我没有任何使用bazel. 因此,如果有人知道如何以tink任何方式构建 Google库,我也愿意接受这些选择。

我正在使用:

  • 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写好后,整个项目是在一个单一的巴泽尔的工作空间现在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

请注意,C++ 实现还支持使用 CMake,这可能更容易满足您的目的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章