【发布时间】:2019-07-11 12:16:17
【问题描述】:
我想为 android armeabi 构建 cryptopp。指南在这里:https://github.com/noloader/cryptopp-android
git clone http://github.com/weidai11/cryptopp.git
cd cryptopp
git submodule add http://github.com/noloader/cryptopp-android.git android
git submodule update --remote
cp "$PWD/android/Android.mk" "$PWD"
cp "$PWD/android/Application.mk" "$PWD"
打开Application.mk文件,修改一些变量
APP_ABI := all → APP_ABI := armeabi
APP_STL := c++_shared → APP_STL := gnustl_shared
然后,设置环境变量:
export ANDROID_SDK_ROOT=/Users/user/Library/Android/sdk/
export ANDROID_NDK_ROOT=/Users/user/Downloads/android-ndk-r16b/
构建命令:android-ndk-r16b/ndk-build V=1 NDK_PROJECT_PATH="$PWD" NDK_APPLICATION_MK="$PWD/Application.mk" NDK_HOST_32BIT=1
错误如下:
> android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/5.0.300080/include/arm_neon.h:28:2:
error: "NEON support not enabled"
#error "NEON support not enabled" ^ android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/5.0.300080/include/arm_neon.h:48:24:
error: 'neon_vector_type' attribute is not
supported for this target typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t;
编辑
我推荐了 config_asm.h 文件中的所有 CRYPTOPP 标志。错误信息在这里
$android-ndk-r16b/ndk-build NDK_PROJECT_PATH="$PWD" NDK_APPLICATION_MK="$PWD/Application.mk"
/home/android-ndk-r16b/build/core/setup-app.mk:81: Android NDK: Application targets deprecated ABI(s): armeabi
/home/android-ndk-r16b/build/core/setup-app.mk:82: Android NDK: Support for these ABIs will be removed in a future NDK release.
[armeabi] Compile++ thumb: cryptopp_shared <= cryptlib.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= cpu.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= integer.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= 3way.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= adler32.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= algebra.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= algparam.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= arc4.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= aria.cpp
[armeabi] Compile++ thumb: cryptopp_shared <= aria_simd.cpp
In file included from /home/crypto++/cryptopp/aria_simd.cpp:19:0:
/home/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/include/arm_neon.h:31:2: error: #error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h
#error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h
^
/home/crypto++/cryptopp/aria_simd.cpp:65:34: error: 'uint32x4_t' does not name a type
inline void ARIA_GSRK_NEON(const uint32x4_t X, const uint32x4_t Y, byte RK[16])
^
/home/crypto++/cryptopp/aria_simd.cpp:65:54: error: 'uint32x4_t' does not name a type
inline void ARIA_GSRK_NEON(const uint32x4_t X, const uint32x4_t Y, byte RK[16])
^
/home/crypto++/cryptopp/aria_simd.cpp: In function 'void CryptoPP::ARIA_UncheckedSetKey_Schedule_NEON(CryptoPP::byte*, CryptoPP::word32*, unsigned int)':
/home/crypto++/cryptopp/aria_simd.cpp:80:8: error: 'uint32x4_t' does not name a type
const uint32x4_t w0 = vld1q_u32(ws+ 0);
^
/home/crypto++/cryptopp/aria_simd.cpp:81:8: error: 'uint32x4_t' does not name a type
const uint32x4_t w1 = vld1q_u32(ws+ 8);
^
/home/crypto++/cryptopp/aria_simd.cpp:82:8: error: 'uint32x4_t' does not name a type
const uint32x4_t w2 = vld1q_u32(ws+12);
^
/home/crypto++/cryptopp/aria_simd.cpp:83:8: error: 'uint32x4_t' does not name a type
const uint32x4_t w3 = vld1q_u32(ws+16);
^
/home/crypto++/cryptopp/aria_simd.cpp:85:21: error: 'w0' was not declared in this scope
ARIA_GSRK_NEON<19>(w0, w1, rk + 0);
^
/home/crypto++/cryptopp/aria_simd.cpp:85:25: error: 'w1' was not declared in this scope
ARIA_GSRK_NEON<19>(w0, w1, rk + 0);
^
/home/crypto++/cryptopp/aria_simd.cpp:86:25: error: 'w2' was not declared in this scope
ARIA_GSRK_NEON<19>(w1, w2, rk + 16);
^
/home/crypto++/cryptopp/aria_simd.cpp:87:25: error: 'w3' was not declared in this scope
ARIA_GSRK_NEON<19>(w2, w3, rk + 32);
^
/home/crypto++/cryptopp/aria_simd.cpp: In function 'void CryptoPP::ARIA_ProcessAndXorBlock_NEON(const byte*, CryptoPP::byte*, const byte*, CryptoPP::word32*)':
/home/crypto++/cryptopp/aria_simd.cpp:136:22: error: 'vld1q_u8' was not declared in this scope
vld1q_u8(xorBlock),
^
/home/crypto++/cryptopp/aria_simd.cpp:139:31: error: 'vrev32q_u8' was not declared in this scope
vrev32q_u8(vld1q_u8((rk))))));
^
/home/crypto++/cryptopp/aria_simd.cpp:139:32: error: 'veorq_u8' was not declared in this scope
vrev32q_u8(vld1q_u8((rk))))));
^
/home/crypto++/cryptopp/aria_simd.cpp:139:33: error: 'veorq_u8' was not declared in this scope
vrev32q_u8(vld1q_u8((rk))))));
^
/home/crypto++/cryptopp/aria_simd.cpp:139:33: error: redeclaration of '<typeprefixerror>veorq_u8'
/home/crypto++/cryptopp/aria_simd.cpp:139:32: note: previous declaration '<typeprefixerror>veorq_u8'
vrev32q_u8(vld1q_u8((rk))))));
^
/home/crypto++/cryptopp/aria_simd.cpp:139:34: error: 'vst1q_u8' was not declared in this scope
vrev32q_u8(vld1q_u8((rk))))));
^
/home/crypto++/cryptopp/aria_simd.cpp:145:22: error: 'vld1q_u8' was not declared in this scope
vld1q_u8(outBlock),
^
/home/crypto++/cryptopp/aria_simd.cpp:146:28: error: 'vrev32q_u8' was not declared in this scope
vrev32q_u8(vld1q_u8(rk))));
^
/home/crypto++/cryptopp/aria_simd.cpp:146:29: error: 'veorq_u8' was not declared in this scope
vrev32q_u8(vld1q_u8(rk))));
^
/home/crypto++/cryptopp/aria_simd.cpp:146:30: error: 'vst1q_u8' was not declared in this scope
vrev32q_u8(vld1q_u8(rk))));
^
make: *** [/home/crypto++/cryptopp/obj/local/armeabi/objs/cryptopp_shared/aria_simd.o] Error 1
【问题讨论】:
-
仅供参考:除非您的 Android 设备已经使用了 10 年以上,否则它几乎肯定会基于 ARMv7 或 ARMv8 架构。较新版本的 NDK 甚至不支持过时的 ARMv5 (armeabi) 架构。
-
我认为我知道问题出在哪里。作为创可贴,打开
config_asm.h(或config.h)并在顶部附近取消注释CRYPTOPP_DISABLE_ASM。另请参阅 Crypto++ wiki 上的 Android.mk (Command Line)。 -
@jww 我做了,现在我得到一个不同的错误。 #error 您必须启用 NEON 指令(例如 -mfloat-abi=softfp -mfpu=neon)才能使用 arm_neon.h
-
我将 LOCAL_CFLAGS := -DHAVE_NEON=1 添加到 Android.mk 文件中。但这并不能解决这个问题。
-
不,这行不通。我认为我们需要为您进行一些源代码更改。 ARM 真的很痛苦,因为所有的编译器都在做自己的事情。不遵循 ARM ACLE 约定。 Android 有点糟糕,因为它自己做事,而且它使用经过修改的工具链,这让我们更加困难。我们正在Issue 863 跟踪此事。
标签: android android-ndk crypto++