Liking error with NDK 26

146 views
Skip to first unread message

AndroidGuy

unread,
Sep 28, 2023, 10:53:14 AM9/28/23
to Crypto++ Users
I'm encounting linking error if I use NDK 26.0.10792818 using LLVM 17 to compile my project with Crypto 8.8, but it works fine with NDK 25.2.9519653 using LLVM 14.
 
F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a -latomic -target aarch64-none-linux-android22 -no-canonical-prefixes  -Wl,--gc-sections  -Wl,--build-id=sha1 -Wl,--no-rosegment  -Wl,--exclude-libs,ALL -Wl,--gc-sections -Wl,--strip-all, -llog -static-libstdc++ -Wl,--no-undefined -Wl,--fatal-warnings -Wl,--no-undefined-version -llog -landroid -lz -lGLESv2 -lc -lm -o F:\Mobile-Modding\App-Project\/obj/local/arm64-v8a/libab.so
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(chacha_avx.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(donna_sse.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(lsh256_avx.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(lsh256_sse.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(lsh512_avx.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(lsh512_sse.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(sse_simd.o) is incompatible with aarch64linux
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [D:/AndroidSDK/ndk/26.0.10792818/build/../build/core/build-binary.mk:654: F:\Mobile-Modding\App-Project\/obj/local/arm64-v8a/libab.so] Error 1
PS F:\Mobile-Modding\App-Project> ./compile26
[arm64-v8a] SharedLibrary  : libab.so
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(chacha_avx.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(donna_sse.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(lsh256_avx.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(lsh256_sse.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(lsh512_avx.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(lsh512_sse.o) is incompatible with aarch64linux      
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/arm64-v8a/libcryptopp.a(sse_simd.o) is incompatible with aarch64linux        
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [D:/AndroidSDK/ndk/26.0.10792818/build/../build/core/build-binary.mk:654: F:\Mobile-Modding\App-Project\/obj/local/arm64-v8a/libab.so] Error 1
make: *** Waiting for unfinished jobs....
[armeabi-v7a] SharedLibrary  : libab.so
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/armeabi-v7a/libcryptopp.a(chacha_avx.o) is incompatible with armelf_linux_eabi
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/armeabi-v7a/libcryptopp.a(donna_sse.o) is incompatible with armelf_linux_eabi
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/armeabi-v7a/libcryptopp.a(lsh256_avx.o) is incompatible with armelf_linux_eabi
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/armeabi-v7a/libcryptopp.a(lsh256_sse.o) is incompatible with armelf_linux_eabi
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/armeabi-v7a/libcryptopp.a(lsh512_avx.o) is incompatible with armelf_linux_eabi
i
ld.lld: error: F:/Mobile-Modding/App-Project//jni/cryptopp/armeabi-v7a/libcryptopp.a(sse_simd.o) is incompatible with armelf_linux_eabi
clang++: error: linker command failed with exit code 1 (use -v to see invocation)  
make: *** [D:/AndroidSDK/ndk/26.0.10792818/build/../build/core/build-binary.mk:654: F:\Mobile-Modding\App-Project\/obj/local/armeabi-v7a/libab.so] Error 1

This is how I add static lib to Android.mk

include $(CLEAR_VARS)
LOCAL_MODULE := cryptopp
LOCAL_SRC_FILES := cryptopp/$(TARGET_ARCH_ABI)/libcryptopp.a
include $(PREBUILT_STATIC_LIBRARY)

LOCAL_STATIC_LIBRARIES := libcurl libssl libcrypto cryptopp # dobby

I compiled the static lib libcryptopp.a with NDK 26.0.10792818 on Linux Mint 21. I tried to compile using NDK 25.2.9519653, it make no difference

This is my script to compile libs

for arch in armeabi-v7a arm64-v8a x86 x86_64
do
    source ./TestScripts/setenv-android.sh 22 $arch
    if [ "$?" -eq "0" ]; then
        make -j4 -f GNUmakefile-cross distclean
        make -j4 -f GNUmakefile-cross static dynamic
        sudo make -j4 -f GNUmakefile-cross install PREFIX=/usr/local/cryptopp/android-$arch
        mkdir -p ./lib/$arch && cp -rf ./libcryptopp.a ./lib/$arch/libcryptopp.a
    fi
done

 

Jeffrey Walton

unread,
Sep 28, 2023, 1:41:46 PM9/28/23
to Crypto++ Users
On Thursday, September 28, 2023 at 10:53:14 AM UTC-4 AndroidGuy wrote:
I'm encounting linking error if I use NDK 26.0.10792818 using LLVM 17 to compile my project with Crypto 8.8, but it works fine with NDK 25.2.9519653 using LLVM 14.


That's kind of interesting in a morbid sort of way.

Have a look at <https://www.cryptopp.com/wiki/Android.mk>. It is the documentation we have for Android.mk-based projects.

I may have some time to look at the problem with NDK 26 this weekend.

Jeff

AndroidGuy

unread,
Sep 29, 2023, 5:42:55 AM9/29/23
to Crypto++ Users
Sadly, using Android build files does not generate statically linked lib (.a file). I wanted to use static lib instead shared libs

Jeffrey Walton

unread,
Sep 29, 2023, 11:01:03 AM9/29/23
to Crypto++ Users
On Friday, September 29, 2023 at 5:42:55 AM UTC-4 AndroidGuy wrote:
Sadly, using Android build files does not generate statically linked lib (.a file). I wanted to use static lib instead shared libs


Jeff

AndroidGuy

unread,
Sep 30, 2023, 12:42:45 PM9/30/23
to Crypto++ Users
Ok. I got it setup and cryptopp is now working on NDK 26
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages