Unsolved Android - How to install .so file?
-
@ekkescorner Yes, I use the same .so for every project.
-
@luca I'm not the cmd line expert - only a mobile app developer ;-)
so please excuse my questions. am I right with my commands below ?
CC=<ANDROID_NDK_PATH>/toolchains/arm-linux-androideabi-<VER>/prebuilt/<NDK_HOST>/bin/arm-linux-androideabi-gcc AR=<ANDROID_NDK_PATH>/toolchains/arm-linux-androideabi-<VER>/prebuilt/<NDK_HOST>/bin/arm-linux-androideabi-ar ANDROID_DEV=<ANDROID_NDK_PATH>/platforms/<ANDROID-PLATFORM>/arch-arm/usr
will execute inside Terminal on OSX
is -4.9 the correct version ?
the <NDK_HOST> I found following the path as darwin-x86_64
as <ANDROID-PLATFORM> I used the newest from r10e: android-21cd <directory-where extracted openssl>/openssl-1.0.2k export ANDROID_NDK_ROOT=/daten/_android/android-ndk-r10e CC=$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc AR=$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ar ANDROID_DEV=$ANDROID_NDK_ROOT/platforms/android-21/arch-arm/usr
as next
./Configure shared android or android-armv7
don't know what to choose - probably this:
./Configure shared android-armv7
then doing the mentioned replaces and finally
make build_libs
will do the job ?
thanks
-
@ekkescorner I followed those steps but I'm working on Linux so I can't confirm it works on Mac.
I used:
./Configure shared android-armv7
because that way you can cover almost all current Android devices.
-
@luca thx - will try it out
-
@luca did all.
configuration was donedid changes in Makefile
then make build_libs fails:
Configured for android-armv7. ekkes-MBP:openssl-1.0.2k admin$ make build_libs making all in crypto... /usr/bin/perl ../util/mkbuildinf.pl "gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -march=armv7-a -mandroid -I/include -B/lib -O3 -fomit-frame-pointer -Wall -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DBSAES_ASM -DGHASH_ASM" "android-armv7" >buildinf.h gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -march=armv7-a -mandroid -I/include -B/lib -O3 -fomit-frame-pointer -Wall -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DBSAES_ASM -DGHASH_ASM -c -o cryptlib.o cryptlib.c clang: error: unknown argument: '-mandroid' make[1]: *** [cryptlib.o] Error 1 make: *** [build_crypto] Error 1
any idea what went wrong ?
-
-
@luca just asked in interests list - perhaps I got some info there
-
@ekkescorner Ok,
anyway I just tryed on my Linux PC and it worked:cd openssl-1.0.2h export AR=/home/luca/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar export CC=/home/luca/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc export LD=/home/luca/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld export ANDROID_DEV=/home/luca/android-ndk-r10e/platforms/android-21/arch-arm/usr ./Configure shared android-armv7 make depend make build_libs
-
@luca difference is
OSX
1.0.2kand what does
make depend ? -
@luca just also tried 1.0.2.h
got info to execute make depend
then error:
Configured for android-armv7. *** Because of configuration changes, you MUST do the following before *** building: make depend ekkes-MBP:openssl-1.0.2h admin$ make depend making depend in crypto... clang: error: unknown argument: '-mandroid' make[1]: *** [local_depend] Error 1 make: *** [depend] Error 1
-
@luca said in Android - How to install .so file?:
@ekkescorner Do you get the same error if you try
./Configure shared android
?
got the same error
who has successfully installed openssl for Qt 5.8 on OSX ?
-
@luca said in Android - How to install .so file?:
@ekkescorner Ok,
anyway I just tryed on my Linux PC and it worked:cd openssl-1.0.2h
...
export LD=/home/luca/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld
why have you added this line ?
and should I use 'export AR= and CC=' instead of AR= and CC= in docs ?thx again
-
found https://github.com/openssl/openssl/issues/1531 and https://bruteforce.gr/bypassing-clang-error-unknown-argument.html
and tried to add at first line
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-futuredidn't work - same error
also I guess GCC is used because of
CC=$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc
so the error shouldn't happen ?also found https://github.com/android-ndk/ndk/issues/5 mentioning 1.0.2g added -mandroid,
so I tried downloading 1.0.2f
same errorI'm lost now - no one out there on OSX already added openssl libs to Qt 5.8 ?
thx
ekke -
@ekkescorner I used "export" because otherwise my bash terminal didn't use the environmental variables.
LD is used to force the android version of the linker. Don't know if you can avoid it. -
@luca said in Android - How to install .so file?:
@ekkescorner I used "export" because otherwise my bash terminal didn't use the environmental variables.
LD is used to force the android version of the linker. Don't know if you can avoid it.did the same
now another error - probably the LD is only needed on Linux ?
ekkes-MBP:openssl-1.0.2k admin$ make build_libs making all in crypto... /usr/bin/perl ../util/mkbuildinf.pl "/daten/_android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -march=armv7-a -mandroid -I/include -B/lib -O3 -fomit-frame-pointer -Wall -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DBSAES_ASM -DGHASH_ASM" "android-armv7" >buildinf.h /daten/_android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -march=armv7-a -mandroid -I/include -B/lib -O3 -fomit-frame-pointer -Wall -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DBSAES_ASM -DGHASH_ASM -c -o cryptlib.o cryptlib.c In file included from cryptlib.c:117:0: cryptlib.h:62:21: fatal error: stdlib.h: No such file or directory # include <stdlib.h> ^ compilation terminated. make[1]: *** [cryptlib.o] Error 1 make: *** [build_crypto] Error 1
-
created a Bug: https://bugreports.qt.io/browse/QTBUG-59375 - will make it easier to follow
-
from Android list I got a link to: https://github.com/orangefour/android-openssl
cloned this repo, modified pathes in .pri
build and run app on Android 7 and it works - so I can go on :)
but this way is no solution for my projects because prebuilt .so are used
would be a security holeso I'm still waiting for an answer HowTo install openssl on OSX following https://github.com/orangefour/android-openssl
-
finally did it the secure way and built from openssl sources on OSX :)
used the .sh scripts from https://github.com/orangefour/android-openssl
in Terminal:
cd <path/to/scripts> chmod 755 ./build-all-arch.sh chmod 755 ./setenv-android-mod.sh export ANDROID_NDK_ROOT=/daten/_android/android-ndk-r10e export OPENSSL_VERSION="openssl-1.0.2k" ./build-all-arch.sh
inside projects adding a .pri pointing to the .so files:
android { ANDROID_EXTRA_LIBS += $$PWD/my/path/to/prebuilt/armeabi-v7a/libcrypto.so ANDROID_EXTRA_LIBS += $$PWD/my/path/to/android-openssl/prebuilt/armeabi-v7a/libssl.so }
will blog about in detail
-
-
@ekkescorner Thanks for sharing !