如何在 C++ 中使用 bazel 构建 Google tink 库?
How to build Google tink library using bazel in C++?
我想为我的应用程序使用 Google tink
库。我使用 android ndk
绑定我的代码。但是,我无法使用 bazel
构建 Google tink
库。我在 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
子目录是它自己独立的工作区,所以在执行 bazel
.
之前你需要 cd
进入它
正确说明:
# 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,为了您的目的,它可能更容易升级。
我想为我的应用程序使用 Google tink
库。我使用 android ndk
绑定我的代码。但是,我无法使用 bazel
构建 Google tink
库。我在 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
子目录是它自己独立的工作区,所以在执行 bazel
.
cd
进入它
正确说明:
# 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,为了您的目的,它可能更容易升级。