简体   繁体   English

无法在 Windows 上为 Android 构建 Botan

[英]Unable to build Botan for Android on Windows

I cannot understand how to build Botan for android, according on the instruction here :根据 此处的说明,我无法理解如何为 android 构建 Botan:

$ export CXX=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++ $ export CXX=/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++

$ ./configure.py --os=android --cc=clang --cpu=arm64 $ ./configure.py --os=android --cc=clang --cpu=arm64

i cannot understand how to use this commands on Windows, also reading previous issues did not help me, can you tell me how did you build this library on windows step-by-step, just your command examples?我不明白如何在 Windows 上使用这个命令,阅读以前的问题也没有帮助我,你能告诉我你是如何在 Windows 上逐步构建这个库的,只是你的命令示例?

I used --cc-bin option of configure.py to specify the path to the compiler, it is considered a solution for windows, but what i have is:我用configure.py--CC-bin选项来指定路径的编译器,它被认为是一个用于Windows的解决方案,但我有什么是:

D:\Programming\Libraries\botanAndroid\botan-master>python configure.py --cc-bin=D:\Android\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++ --os=android --cc=clang --cpu=armv7
INFO: configure.py invoked with options "--cc-bin=D:\Android\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++ --os=android --cc=clang --cpu=armv7"
INFO: Configuring to build Botan 2.14.0 (revision unknown)
INFO: Running under 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]
INFO: Autodetected platform information: OS="Windows" machine="AMD64" proc="Intel64 Family 6 Model 142 Stepping 10, GenuineIntel"
INFO: Canonicalized CPU target armv7 to arm32
WARNING: Could not execute ['D:\Android\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++', '-E', 'src\build-data\detect_version.cpp']: [WinError 193] %1 is not an application of Win32
WARNING: Tried to get clang version, but output '0.0' does not match expected version format
WARNING: Could not execute ['D:\Android\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++', '-E', '-fstack-protector', '-pthread', 'src\build-data\detect_arch.cpp']: [WinError 193] %1 is not an application of Win32
WARNING: Unable to detect target architecture via compiler macro checks
INFO: Target is clang:0.0-android-arm32
INFO: Assuming target arm32 is little endian
INFO: Skipping (dependency failure): asio certstor_sqlite3 rdrand sessions_sqlite3
INFO: Skipping (incompatible CPU): aes_armv8 aes_ni aes_power8 chacha_avx2 clmul_cpu clmul_ssse3 idea_sse2 p9_darn rdrand_rng rdseed serpent_avx2 sha1_armv8 sha1_sse2 sha1_x86 sha2_32_armv8 sha2_32_bmi2 sha2_32_x86 sha2_64_bmi2 sha3_bmi2 shacal2_avx2 shacal2_x86 simd_avx2 sm4_armv8 threefish_512_avx2
INFO: Skipping (incompatible OS): certstor_system_macos certstor_system_windows commoncrypto getentropy proc_walk win32_stats
INFO: Skipping (no enabled compression schemes): compression
INFO: Skipping (requires external dependency): boost bzip2 lzma openssl sqlite3 tpm zlib
INFO: Loading modules: adler32 aead aes aes_vperm aont argon2 aria asn1 auto_rng base base32 base58 base64 bcrypt bcrypt_pbkdf bigint blake2 block blowfish camellia cascade cast128 cast256 cbc cbc_mac ccm cecpq1 certstor_flatfile certstor_sql certstor_system cfb chacha chacha20poly1305 chacha_rng chacha_simd32 checksum cmac comb4p cpuid crc24 crc32 cryptobox ctr curve25519 des dev_random dh dl_algo dl_group dlies dsa dyn_load eax ec_group ecc_key ecdh ecdsa ecgdsa ecies eckcdsa ed25519 elgamal eme_oaep eme_pkcs1 eme_raw emsa1 emsa_pkcs1 emsa_pssr emsa_raw emsa_x931 entropy fd_unix ffi filters fpe_fe1 gcm gmac gost_28147 gost_3410 gost_3411 hash hash_id hex hkdf hmac hmac_drbg hotp http_util idea iso9796 kasumi kdf kdf1 kdf1_iso18033 kdf2 keccak keypair lion locking_allocator mac mce mceies md4 md5 mdx_hash mem_pool mgf1 misty1 mode_pad modes mp newhope nist_keywrap noekeon noekeon_simd numbertheory ocb ofb par_hash passhash9 pbes2 pbkdf pbkdf1 pbkdf2 pem pgp_s2k pk_pad pkcs11 poly1305 poly_dbl prf_tls prf_x942 psk_db pubkey rc4 rfc3394 rfc6979 rmd160 rng roughtime rsa salsa20 scrypt seed serpent serpent_simd sessions_sql sha1 sha2_32 sha2_64 sha3 shacal2 shacal2_simd shake shake_cipher simd siphash siv skein sm2 sm3 sm4 socket sodium sp800_108 sp800_56a sp800_56c srp6 stateful_rng stream streebog system_rng thread_utils threefish_512 tiger tls tls_10 tls_cbc tss twofish utils uuid whirlpool x509 x919_mac xmss xtea xts
INFO: Using hardlink to link files into build dir (use --link-method to change)
INFO: Botan 2.14.0 (revision unknown) (unreleased undated) build setup is complete

Now i'm currently using VisualStudio 2017 native tool command prompt, or calling vcvarsall.bat, to set up the environment.现在我正在使用 VisualStudio 2017 本机工具命令提示符或调用 vcvarsall.bat 来设置环境。

It seems Botan support for building Android binaries on Windows hosts is limited.似乎 Botan 对在 Windows 主机上构建 Android 二进制文件的支持是有限的。 You will have to use dark magic to make this work.你将不得不使用黑魔法来完成这项工作。

The build process consists of two phases, the configuration phase and the make phase.构建过程包括两个阶段,配置阶段和制作阶段。

The Android-specific instructions in the documentation you linked do not cover the whole build process, only the configuration phase.您链接的文档中特定于 Android 的说明不涵盖整个构建过程,仅涵盖配置阶段。 For the make phase, you then have to follow the Windows-specific instructions ( link ).对于 make 阶段,您必须遵循特定于 Windows 的说明( 链接)。

Configuration phase:配置阶段:

You will need the following binaries, adjust the paths to your machine:您将需要以下二进制文件,调整您机器的路径:

  • clang++ (note the .cmd at the end): C:\\Development\\android-ndk-r19c-windows-x86_64\\android-ndk-r19c\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi28-clang++.cmd clang++(注意最后的.cmd ): C:\\Development\\android-ndk-r19c-windows-x86_64\\android-ndk-r19c\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\armv7a-linux-androideabi28-clang++.cmd

  • ar: C:\\Development\\android-ndk-r19c-windows-x86_64\\android-ndk-r19c\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\arm-linux-androideabi-ar.exe ar: C:\\Development\\android-ndk-r19c-windows-x86_64\\android-ndk-r19c\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\arm-linux-androideabi-ar.exe

In the Botan folder, run the configure command:在 Botan 文件夹中,运行configure命令:

python.exe .\configure.py --cc-bin=C:\Development\android-ndk-r19c-windows-x86_64\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\armv7a-linux-androideabi28-clang++.cmd --ar-command=C:\Development\android-ndk-r19c-windows-x86_64\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ar.exe --os=android --cpu=armv7 --verbose

Make phase制作阶段

The configuration phase generates a Makefile in the Botan folder.配置阶段在 Botan 文件夹中生成一个Makefile You will have to make some adjustments to this file:您必须对此文件进行一些调整:

  • In the line all: libs cli tests docs remove docsall: libs cli tests docs行中all: libs cli tests docs remove docs

    Reason: Additional tools are needed for building the documentation files.原因:需要额外的工具来构建文档文件。 If you really need the documentation, you could also try to install these tools, but I have not tested this.如果你真的需要文档,你也可以尝试安装这些工具,但我没有测试过。

  • Replace the occurrences of ln -fs with copy .将出现的ln -fs替换为copy

    Reason: On Linux ln -fs would create a symbolic link from the second file in the parameter list to the first.原因:在 Linux 上ln -fs会创建一个从参数列表中的第二个文件到第一个文件的符号链接。 This command is not available, so changing it to copying the first file to the second seems like a pragmatic work-around to me.此命令不可用,因此将其更改为将第一个文件复制到第二个文件对我来说似乎是一种务实的解决方法。 You could also change it to the appropriate command for creating a link on Windows, but then you might have to adjust it again when deploying to your Android target.您也可以将其更改为在 Windows 上创建链接的适当命令,但是在部署到 Android 目标时可能需要再次调整它。

  • In the lines starting with LIBOBJS = , CLIOBJS = and TESTOBJS = , replace all occurrences of \\ with / .在以LIBOBJS =CLIOBJS =TESTOBJS =开头的行中,将所有出现的\\替换为/ In the whole file, replace occurrences of .\\ with ./ .在整个文件中,将出现的.\\替换为./ Reason: Using the Windows-style path separator \\ seems to cause problems in some places.原因:使用 Windows 风格的路径分隔符\\似乎在某些地方会导致问题。

  • Find the block with # Executable targets and # Library targets .查找与块# Executable targets# Library targets Insert @<< ... << around the parameter lists (known as the nmake inline file feature, based on this answer), to make it look like this:在参数列表(称为 nmake 内联文件功能,基于答案)周围插入@<< ... << ,使其看起来像这样:

# Executable targets
$(CLI): $(LIBRARIES) $(CLIOBJS)
  $(EXE_LINK_CMD) @<<
$(ABI_FLAGS) $(CLIOBJS) $(EXE_LINKS_TO) $(LDFLAGS) -o $@
<<

$(TEST): $(LIBRARIES) $(TESTOBJS)
  $(EXE_LINK_CMD) @<<
$(ABI_FLAGS) $(TESTOBJS) $(EXE_LINKS_TO) $(LDFLAGS) -o $@
<<

# Library targets
./libbotan-2.a: $(LIBOBJS)
  $(AR) @<<
$(AR_OPTIONS) $@ $(LIBOBJS)
<<

./libbotan-2.so.13: $(LIBOBJS)
  $(CXX) @<<
-shared -fPIC -Wl,-soname,libbotan-2.so.13  $(ABI_FLAGS) $(LDFLAGS) $(LIBOBJS) $(LIB_LINKS_TO) -o $@
<<

Reason: Without this change, I got an error about the parameter list being too long.原因:如果没有此更改,我会收到关于参数列表太长的错误。

You will need nmake (part of Visual Studio).您将需要 nmake(Visual Studio 的一部分)。 On my machine it is installed in C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\bin\\Hostx64\\x64\\nmake.exe在我的机器上,它安装在C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\bin\\Hostx64\\x64\\nmake.exe

In the Botan folder, run nmake.exe .在 Botan 文件夹中,运行nmake.exe Afterwards, your Botan folder should contain the binaries botan , botan-test and libraries libbotan-2... .之后,你的牡丹文件夹应包含二进制botanbotan-test和库libbotan-2...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM