簡體   English   中英

如何在 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 工作區中。 現在的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

請注意, C++ 實現還支持使用 CMake ,這可能更容易為您的目的而加速。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM