I am trying to generate the shared library for the (.so) files of the OpenSSL1.0.1c for the Android. I found that they have added three options for compiling for the Android in the android script.
./Configure android-armv7 (or)
./Configure android-x86 (or)
./Configure android
once I configured for the OS and then try to compile, its throwing errors.
Currently I am working x86 windows7 and installed Cygwin, Android sdk R20, Android NDK r8
sh-4.1$ make
making all in crypto...
make[1]: Entering directory `/cygdrive/d/SourceCodes/OpenSSL/openssl-1.0.1c/crypto'
gcc -I. -I.. -I../include -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 -DOP
ENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DGHASH_ASM -c -o cryptlib.o cryptlib.c
cc1: error: unrecognized command line option "-mandroid"
cryptlib.c:1:0: error: bad value (armv7-a) for -march= switch
<builtin>: recipe for target `cryptlib.o' failed
make[1]: *** [cryptlib.o] Error 1
make[1]: Leaving directory `/cygdrive/d/SourceCodes/OpenSSL/openssl-1.0.1c/crypto'
Makefile:278: recipe for target `build_crypto' failed
make: *** [build_crypto] Error 1
sh-4.1$
Please let me know if anyone faced the similar issue and got the solution for resolving the same.
I would seriously not advise to grab anything outside of the official OpenSSL web site. You cannot take a chance when dealing with cryptography and security.
The only problem that I see is that you are using your host's gcc rather than using android's cross compilers.
Here is how I would compile the official OpenSSL on Ubuntu 14.04LTS (this works with OpenSSL 1.0.1g)
From your home folder, run the following commands:
tar xzvf ~/Downloads/openssl-1.0.1g.tar.gz
cd openssl-1.0.1g
export NDK=~/android-ndk-r9d
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --toolchain=arm-linux-androideabi-4.6 --install-dir=`pwd`/android-toolchain-arm
export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm/bin
export TOOL=arm-linux-androideabi
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
export ARCH_LINK="-march=armv7-a -Wl,--fix-cortex-a8"
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
And then run your configure script:
./Configure android-armv7
And then build
PATH=$TOOLCHAIN_PATH:$PATH make
You should see that it is using arm-linux-androideabi-gcc instead of gcc
To build for the old armeabi:
tar xzvf ~/Downloads/openssl-1.0.1g.tar.gz
cd openssl-1.0.1g
export NDK=~/android-ndk-r9d
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --toolchain=arm-linux-androideabi-4.6 --install-dir=`pwd`/android-toolchain-arm
export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm/bin
export TOOL=arm-linux-androideabi
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS="-mthumb"
export ARCH_LINK=
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
./Configure android
make clean
PATH=$TOOLCHAIN_PATH:$PATH make
to build for x86 :
tar xzvf ~/Downloads/openssl-1.0.1g.tar.gz
cd openssl-1.0.1g
export NDK=~/android-ndk-r9d
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --toolchain=x86-4.6 --install-dir=`pwd`/android-toolchain-x86
export TOOLCHAIN_PATH=`pwd`/android-toolchain-x86/bin
export TOOL=i686-linux-android
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS="-march=i686 -msse3 -mstackrealign -mfpmath=sse"
export ARCH_LINK=
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
./Configure android-x86
make clean
PATH=$TOOLCHAIN_PATH:$PATH make
In OpenSSL 1.0.1e, all I need to do is:
CC=~/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc ./Configure android-armv7
ANDROID_DEV=~/android-ndk-r9//platforms/android-8/arch-arm/usr make build_libs
Thanks to the instructions posted here, plus some other additions, I've made an automated script which compiles the latest OpenSSL library for Android with support for: armeabi, armeabi-v7a, x86, x86_64 and arm64-v8a:
#!/bin/bash -e
##author Aleksandar Gotev (alex.gotev#mobimesh.it)
#Hints and code taken also from http://stackoverflow.com/questions/11929773/compiling-the-latest-openssl-for-android
if [ "$#" -ne 6 ]
then
echo "Usage:"
echo "./openssl-build <ANDROID_NDK_PATH> <OPENSSL_SOURCES_PATH> <ANDROID_TARGET_API> \\"
echo " <ANDROID_TARGET_ABI> <GCC_VERSION> <OUTPUT_PATH>"
echo
echo "Supported target ABIs: armeabi, armeabi-v7a, x86, x86_64, arm64-v8a"
echo
echo "Example using GCC 4.8, NDK 10e, OpenSSL 1.0.2d and Android API 21 for armeabi-v7a."
echo "./openssl-build /home/user/android-ndk-r10e \\"
echo " /home/user/openssl-1.0.2d \\"
echo " 21 \\"
echo " armeabi-v7a \\"
echo " 4.8 \\"
echo " /home/user/output/armeabi-v7a"
exit 1
fi
NDK_DIR=$1
OPENSSL_BASE_FOLDER=$2
OPENSSL_TARGET_API=$3
OPENSSL_TARGET_ABI=$4
OPENSSL_GCC_VERSION=$5
OPENSSL_OUTPUT_PATH=$6
NDK_MAKE_TOOLCHAIN="$NDK_DIR/build/tools/make-standalone-toolchain.sh"
OPENSSL_TMP_FOLDER="/tmp/openssl"
rm -rf "$OPENSSL_TMP_FOLDER"
mkdir -p "$OPENSSL_TMP_FOLDER"
cp -r ${OPENSSL_BASE_FOLDER} ${OPENSSL_TMP_FOLDER}
function build_library {
mkdir -p ${OPENSSL_OUTPUT_PATH}
export PATH=$TOOLCHAIN_PATH:$PATH
make && make install
rm -rf ${OPENSSL_TMP_FOLDER}
echo "Build completed! Check output libraries in ${OPENSSL_OUTPUT_PATH}"
}
if [ "$OPENSSL_TARGET_ABI" == "armeabi-v7a" ]
then
${NDK_MAKE_TOOLCHAIN} --platform=android-${OPENSSL_TARGET_API} \
--toolchain=arm-linux-androideabi-${OPENSSL_GCC_VERSION} \
--install-dir="${OPENSSL_TMP_FOLDER}/android-toolchain-arm"
export TOOLCHAIN_PATH="${OPENSSL_TMP_FOLDER}/android-toolchain-arm/bin"
export TOOL=arm-linux-androideabi
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
export ARCH_LINK="-march=armv7-a -Wl,--fix-cortex-a8"
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
cd ${OPENSSL_TMP_FOLDER}
./Configure android-armv7 --openssldir=${OPENSSL_OUTPUT_PATH}
build_library
elif [ "$OPENSSL_TARGET_ABI" == "arm64-v8a" ]
then
${NDK_MAKE_TOOLCHAIN} --platform=android-${OPENSSL_TARGET_API} \
--toolchain=aarch64-linux-android-4.9 \
--install-dir="${OPENSSL_TMP_FOLDER}/android-toolchain-arm64"
export TOOLCHAIN_PATH="${OPENSSL_TMP_FOLDER}/android-toolchain-arm64/bin"
export TOOL=aarch64-linux-android
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS=
export ARCH_LINK=
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
cd ${OPENSSL_TMP_FOLDER}
./Configure android --openssldir=${OPENSSL_OUTPUT_PATH}
build_library
elif [ "$OPENSSL_TARGET_ABI" == "armeabi" ]
then
${NDK_MAKE_TOOLCHAIN} --platform=android-${OPENSSL_TARGET_API} \
--toolchain=arm-linux-androideabi-${OPENSSL_GCC_VERSION} \
--install-dir="${OPENSSL_TMP_FOLDER}/android-toolchain-arm"
export TOOLCHAIN_PATH="${OPENSSL_TMP_FOLDER}/android-toolchain-arm/bin"
export TOOL=arm-linux-androideabi
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS="-mthumb"
export ARCH_LINK=
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
cd ${OPENSSL_TMP_FOLDER}
./Configure android --openssldir=${OPENSSL_OUTPUT_PATH}
build_library
elif [ "$OPENSSL_TARGET_ABI" == "x86" ]
then
${NDK_MAKE_TOOLCHAIN} --platform=android-${OPENSSL_TARGET_API} \
--toolchain=x86-${OPENSSL_GCC_VERSION} \
--install-dir="${OPENSSL_TMP_FOLDER}/android-toolchain-x86"
export TOOLCHAIN_PATH="${OPENSSL_TMP_FOLDER}/android-toolchain-x86/bin"
export TOOL=i686-linux-android
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS="-march=i686 -msse3 -mstackrealign -mfpmath=sse"
export ARCH_LINK=
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
cd ${OPENSSL_TMP_FOLDER}
./Configure android-x86 --openssldir=${OPENSSL_OUTPUT_PATH}
build_library
elif [ "$OPENSSL_TARGET_ABI" == "x86_64" ]
then
${NDK_MAKE_TOOLCHAIN} --platform=android-${OPENSSL_TARGET_API} \
--toolchain=x86_64-4.9 \
--install-dir="${OPENSSL_TMP_FOLDER}/android-toolchain-x86_64"
export TOOLCHAIN_PATH="${OPENSSL_TMP_FOLDER}/android-toolchain-x86_64/bin"
export TOOL=x86_64-linux-android
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
cd ${OPENSSL_TMP_FOLDER}
./Configure linux-x86_64 --openssldir=${OPENSSL_OUTPUT_PATH}
build_library
else
echo "Unsupported target ABI: $OPENSSL_TARGET_ABI"
exit 1
fi
Script docs: https://github.com/alexbbb/pjsip-android-builder#build-only-openssl
For the last version check: https://github.com/alexbbb/pjsip-android-builder/blob/master/openssl-build
I glued together some useful advices here to a build environment for OpenSSL for Android which works for me.
Supports build for multiple architectures - ARM, ARMv7, X86
Uses OpenSSL source codes
Integrated with Android.mk build
Contains pre-compiled OpenSSL 1.0.2h (use if you want or compile your own)
https://github.com/ph4r05/android-openssl
In case someone encounters the problem of using vulnerable version of OpenSSL (< 1.0.2f/1.0.1r) in one of the native libraries, I add some more details and instructions.
Preconditions: Android NDK need to be configured first.
First of all, download the OpenSSL compatible version (> 1.0.2f/1.0.1r).
Download two scripts from this link. In case someone wonders what they do (and you should - it is a cryptographic library!!!): They build the OpenSSL library for every android ABI processor architecture (armeabi, x86, mips, etc...)
Modify setenv-android-mod.sh -> line 18 with the ndk version
Modify setenv-android-mod.sh -> line 40 with the Android API version
Modify build-all-arch.sh -> line 7 with the folder name of the OpenSSL library (in my case it was openssl-1.0.1t)
After successful build, inside the folder dist the libraries will be present
To add the openSSL to project as prebuilt static libraries, create:
openssl folder under jni directory containing lib/ (which contain the .a files for the supported architectures),
include/ which has the necessary includes (you can find that under the openssl version you downloaded, be aware that some of the header files are symbolic links)
Modify Android.mk inside jni folder adding the following:
include $(CLEAR_VARS)
LOCAL_MODULE := libssl
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libssl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcrypto
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libcrypto.a
include $(PREBUILT_STATIC_LIBRARY)
Then, to use the library within another jni module add the following to it's Android.mk file:
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../openssl/include
LOCAL_STATIC_LIBRARIES := libssl libcrypto
This doesn't solve your problem, but perhaps it will help. A google groups post where they have successfully compiled OpenSSL 1.0.1 beta2 for Android.
https://groups.google.com/forum/?fromgroups#!topic/android-security-discuss/5-_gCAmEo-M
This might also help, an open source project that builds 1.0.0a for Android:
https://github.com/eighthave/openssl-android
This is how I did it for openssl-1.0.2g:
$ rm -rf openssl-1.0.2g/
$ tar xzf openssl-1.0.2g.tar.gz
$ chmod a+x setenv-android.sh
$ . ./setenv-android.sh ---> Note: make sure in the same folder of your openssl-1.0.2g
$ cd openssl-1.0.2g/
$ perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
$ ./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine --openssldir=<Path of your OpenSSL>
$ make depend
$ make clean
$ make all
before make install, ---Delete the "include" folder (path/of/your/openssl-1.0.2g/include) or you may move it to another directory for safe keeping.
$ make install
Make sure that you input the right NDK paths into your setenv-android.sh or else you will have errors.
Example for this build I used Android NDK vr10b (http://dl.google.com/android/ndk/android-ndk32-r10b-darwin-x86.tar.bz2)
and used the ff path values inside my setenv-android.sh file:
_ANDROID_NDK="android-ndk-r10b" (Line 12)
_ANDROID_EABI="arm-linux-androideabi-4.8"(Line 16)
_ANDROID_API="android-19"(Line 24)
Reference:
https://wiki.openssl.org/index.php/Android
Note --->
I created a github commit to answer this question, please see: https://github.com/rjmangubat23/OpenSSL
I uploaded the different scripts for setenv-android.sh onto my github, cause you will need different type of scripts for different architectures:
For x86: https://github.com/rjmangubat23/OpenSSL/tree/master/x86
For ArmV7: https://github.com/rjmangubat23/OpenSSL/tree/master/ArmV7
Download Openssl here: ftp://ftp.openssl.org/source
Download Complete list of Android NDK files here: https://github.com/taka-no-me/android-cmake/blob/master/ndk_links.md
You can use this script to compile openssl under Windows 7 + Cygwin. Everything you need is only change location of ndk and choose android api version.
My way step by step (Win 7 x64 + Cygwin + ndk r10c)
Copy file setenv-android-mod.sh and build-all-arch.sh to your openssl directory.
Modify file build-all-arch.sh
cd openssl-1.0.1j to #cd openssl-1.0.1j (line 56)
cd .. to #cd .. (line 80)
Modify file setend-android-mod.sh
_ANDROID_NDK="android-ndk-r10c-x64" change to your ndk version (line 18)
_ANDROID_API="android-19" change to your api version (line 40)
ANDROID_NDK_ROOT="d:/work/android/android-ndk-r10c-x64" specify your dir (line 42)
ANDROID_TOOLCHAIN="d:/work/android/android-ndk-r10c-x64/toolchains" specify your dir (line 43)
export CROSS_COMPILE="aarch64-linux-android-" to export CROSS_COMPILE="$ANDROID_TOOLCHAIN/aarch64-linux-android-" (line 219), change same lines 225, 231, 237, 243 - just add $ANDROID_TOOLCHAIN/ to the cross compile path.
Run build-all-arch.sh.
All libraries (*.so) will be located in /prebuilt/ dir.
P.S. I had a few more errors because of wrong symlinks, but everything was fine after executing the following command export CYGWIN="winsymlinks:native" see here for details.
This problem and many others like it caused me a week or so of mucking about, but I finally cracked it so I thought I'd share my solution. OpenSSL can be compiled for 21+ and work on Android 4.03 devices if you are willing to hack the code. We use libcurl, so wanted to be up to date. The steps are a bit complex:
First up ensure you have a buildable version of libcurl. I recommend as a good starting point https://github.com/cocos2d/cocos2d-x-3rd-party-libs-src
They keep up to date build scripts.
Firstly hack the android.ini in "build" to version 21
Next up I had to add the following stub functions to the jni project somewhere:
// SPECIAL API 21+ functions required for android to build on newer platform targets.
float strtof (const char* str, char** endptr)
{
return (float)strtod(str, endptr);
}
int __isnanf(float x)
{
return (x != x);
}
double atof (const char* s)
{
double rez = 0, fact = 1;
if (*s == '-'){
s++;
fact = -1;
};
for (int point_seen = 0; *s; s++){
if (*s == '.'){
point_seen = 1;
continue;
};
int d = *s - '0';
if (d >= 0 && d <= 9){
if (point_seen) fact /= 10.0f;
rez = rez * 10.0f + (float)d;
};
};
return rez * fact;
}
void srandom(unsigned int seed)
{
std::srand(seed);
}
static unsigned long _next = 1;
void srand(unsigned int seed)
{
_next = seed;
}
long random()
{
return rand();
}
int rand()
{
_next = _next * 1103515245 + 12345;
return (unsigned int)(_next/65536) % 32768;
}
/* the default is bsd */
__sighandler_t signal(int s, __sighandler_t f)
{
return 0;
}
Note the signal function could be better, but for us it isn't important. This stops the dreaded "cannot locate symbol" errors on 4.03 devices caused by changes to the headers in 5+ (https://groups.google.com/forum/#!topic/android-ndk/RjO9WmG9pfE).
Next up download the tar.gz for the version of openssl you want to build and unpack it somewhere. Edit crypto/ui/ui_openssl.c and crypto/des/read_pwd.c and ensure that the #defines for tcsetattr are not used. I used a brute force #if 0 and #if 1 - note this should be possible by twiddling the preprocessor, but I gave up at this point. If anyone feels like sharing the correct magic please do!
Now you need to re-tar up the file into the tarballs file (making sure you get it root folder in there:
and run (in my case)
shasum -a 512 curl-7.50.0.tar.gz > ../src/curl/SHA512SUMS
This will allow the cocos2d ./build.sh to run. Something like:
./build.sh -p=android --libs=openssl,curl --arch=armv7 --mode=release
Finally - and this caught me out in terms of making a universal .a file, but is not directly part of the question, ensure you use a version that doesn't use NEON instructions. Tegra 2 devices apparently have FPU but no NEON. I think this can be done using -mfpu=vfp as a compiler flag, but I chose to just use the armv5 build instead, as performance is not really important to me in this area (and I have had enough nasty real world surprises from this already).
In the end you should get a nice .a that works everywhere, and can be used in projects targeting the latest and greatest Android. Now if only someone from the OpenSSL project can read this and fix the project so it understands android stuff released 2 years ago!
Good luck!
Here is how to build OpenSSL on Windows using Cygwin and Android NDK
Download and extract OpenSSL source
Download script from https://github.com/pstanoev/OpenSSL-For-Android
Run cmd with Administrator user and execute
SET CYGWIN=winsymlinks:nativestrict
In same cmd window, open Cygwin:
cygwin.bat
Make script executable:
chmod +x *.sh
In Cygwin execute:
/cygdrive/c/dev/openssl-source/openssl-build.sh /cygdrive/c/dev/android-ndk-r12b /cygdrive/c/dev/openssl-source/openssl-1.0.2j 15 armeabi-v7a 4.9 /home/user/openssl
Modify for your locations of Android NDK and sources
Copy libcrypto.so and include/* files to this module. Use cp -r for copy to follow links.
Please refer to PJSIP Build For Android with Integration of G729 Codec for compiling latest Openssl for Android. It is quite well explained.
Follow these instructions may help :)
1: Download Android NDK (version ndk-r13b) from this url:
https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip
2: Extract NDK to /home/Android.
3: Download the cross compilation setup script from this URL:
https://wiki.openssl.org/images/7/70/Setenv-android.sh
4: Make following changes in the Setenv-android.sh script:
a: Add the following line to the start of the script
ANDROID_NDK_ROOT=/home/Android/android-ndk-r13b
b: Modify _ANDROID_NDK="android-ndk-r13".
c: Modify _ANDROID_EABI="arm-linux-androideabi-4.9"
d: Modify _ANDROID_API="android-23"
5: Download the openssl (version 1.0.2n) from this url:
https://www.openssl.org/source/old/1.0.2/openssl-1.0.2n.tar.gz
6: Extract the downloaded tarball.
7: Open new terminal window and navigate to extracted directory.
8: Move the Setenv-android.sh script to this directory and execute the following commands:
chmod a+x Setenv-android.sh
source ./Setenv-android.sh
9: Run the following command (to configure OpenSSL sources to build for Android):
./Configure shared android
10: Execute following command to build libcrypto and libssl shared libraries.
make CALC_VERSIONS="SHLIB_COMPAT=; SHLIB_SOVER=" build_libs
11: Let the build complete successfully.
With NDK v22 and openssl-1.0.2o:
export PATH=$(echo -n $ANDROID_NDK/toolchains/llvm/prebuilt/*/bin):$PATH
./Configure android-x86 no-asm
make clean build_libs AR="llvm-ar r" RANLIB="llvm-ranlib" CC=i686-linux-android19-clang CFLAG="-fPIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -D__ANDROID_API__=19 -Os -fomit-frame-pointer -Wall -I$ANDROID_NDK_ROOT/sysroot/usr/include -I$ANDROID_NDK_ROOT/sysroot/usr/include/i686-linux-android"
mkdir -p x86/lib x86/include/openssl
cp lib*.a x86/lib
cp include/openssl/* x86/include/openssl
builds static libs for x86
Related
I have to to build opencv from source due to opencv_contrib. Although I have tried many tutorials, I faild to build opencv from source.
The code I used:
cmake -G"MinGW Makefiles" -DANDROID_NDK=D:/androidNDK/android-ndk-r22b -DANDROID_SDK_ROOT=D:/android-sdk -DCMAKE_TOOLCHAIN_FILE=D:/androidNDK/android-ndk-r22b/build/cmake/android.toolchain.cmake -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF D:/OpenCV455/opencv-4.5.5
General configuration:
-- General configuration for OpenCV 4.5.5 =====================================
-- Version control: unknown
--
-- Platform:
-- Timestamp: 2022-11-19T00:58:08Z
-- Host: Windows 10.0.19043 AMD64
-- Target: Android 1 armv7-a
-- CMake: 3.21.3
-- CMake generator: MinGW Makefiles
-- CMake build tool: D:/MinGW1/mingw64/bin/mingw32-make.exe
-- Configuration: Release
--
-- CPU/HW features:
-- Baseline: NEON
-- requested: DETECT
--
-- C/C++:
-- Built as dynamic libs?: NO
-- C++ standard: 11
-- C++ Compiler: D:/androidNDK/android-ndk-r22b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe (ver 11.0.5)
-- C++ flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -Oz -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info -DDEBUG -D_DEBUG
-- C Compiler: D:/androidNDK/android-ndk-r22b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- C flags (Release): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -Oz -DNDEBUG -DNDEBUG
-- C flags (Debug): -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -fvisibility=hidden -fvisibility-inlines-hidden -O0 -fno-limit-debug-info -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- Linker flags (Debug): -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,--as-needed
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: z dl m log
-- 3rdparty dependencies: libcpufeatures libprotobuf ade ittnotify libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf quirc tegra_hal
--
-- OpenCV modules:
-- To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java ml objdetect photo stitching video videoio
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: python2 python3 ts
-- Applications: android_examples
-- Documentation: NO
-- Non-free algorithms: NO
--
-- Android NDK: D:/androidNDK/android-ndk-r22b (ver 22.1.7171670)
-- Android ABI: armeabi-v7a
-- NDK toolchain: arm-linux-androideabi-clang
-- STL type: c++_static
-- Native API level: 16
-- Android SDK: D:/android-sdk (tools: 25.2.5 build tools: 33.0.0)
-- android tool: D:/android-sdk/tools/android.bat
-- SDK target: android-21
-- Projects build scripts: Ant/Eclipse compatible
--
-- GUI: NONE
--
-- Media I/O:
-- ZLib: z (ver 1.2.11)
-- JPEG: build-libjpeg-turbo (ver 2.1.2-62)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: build (ver 1.6.37)
-- TIFF: build (ver 42 - 4.2.0)
-- JPEG 2000: build (ver 2.4.0)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.19.1)
--
-- Python (for build): D:/Python37/python.exe
--
-- Java: export all functions
-- ant: D:/apache-ant-1.9.16/bin/ant.bat (ver 1.9.16)
-- Java wrappers: YES
-- Java tests: NO
--
-- Install to: D:/OpenCV455/buil36/install
-----------------------------------------------------------------**
The errors I get after running 'mingw32-make':
[97%] Built target opencv_java_android_source_copy
[97%]Generating OpenCV Android library project. SDK target:
[97%] Bui1ding OpenCV Android library project
[subant] No sub-builds to iterate on
Target '-code-gen' failed with message 'The following error occurred while executing this line:
D:\android-sdk\tools\ant\build.xml:655: null returned: -1073741819'.
Cannot execute '-compile' - '-code-gen' failed or was not executed.
Cannot execute '-dex' - '-compile' failed or was not executed.
Cannot execute '-package' - '-dex' failed or was not executed.
Cannot execute '-do-debug' - '-package' failed or was not executed.
Cannot execute 'debug' - '-do-debug' failed or was not executed.
BUILD FAILED
D:\android-sdk\tools\ant\build.xml:649: The following error occurred while executing this line:
D:\android-sdk\tools\ant\build.xml:655: null returned: -1073741819
Total time: 2 seconds
mingw32-make[2]: *** [modules\java\android_sdk\CMakeFiles\opencv_java_android.dir\build.make:77: bin/classes.jar] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:2689: modules/java/android_sdk/CMakeFiles/opencv_java_android.dir/all] Error 2
I get similar errors with ninja.
[1568/1595] Building OpenCV Android library project
FAILED: bin/classes.jar CMakeFiles/dephelper/opencv_java_android D:/OpenCV455/build36/bin/classes.jar D:/OpenCV455/build36/CMakeFiles/dephelper/opencv_java_android
cmd.exe /C "cd /D D:\OpenCV455\build36\android_sdk && D:\apache-ant-1.9.16\bin\ant.bat -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6 && D:\cmake-3.21.3\bin\cmake.exe -E touch D:/OpenCV455/build36/CMakeFiles/dephelper/opencv_java_android"
[subant] No sub-builds to iterate on
Target '-code-gen' failed with message 'The following error occurred while executing this line:
D:\android-sdk\tools\ant\build.xml:655: null returned: -1073741819'.
Cannot execute '-compile' - '-code-gen' failed or was not executed.
Cannot execute '-dex' - '-compile' failed or was not executed.
Cannot execute '-package' - '-dex' failed or was not executed.
Cannot execute '-do-debug' - '-package' failed or was not executed.
Cannot execute 'debug' - '-do-debug' failed or was not executed.
BUILD FAILED
D:\android-sdk\tools\ant\build.xml:649: The following error occurred while executing this line:
D:\android-sdk\tools\ant\build.xml:655: null returned: -1073741819
Total time: 1 second
[1572/1595] Building CXX object modules/gapi/CMakeFiles/opencv_perf_gapi.dir/perf/gpu/gapi_core_perf_tests_gpu.cpp.o
ninja: build stopped: subcommand failed.
here is the code with error.
in build.ninja file:
# Custom command for bin\classes.jar
build bin/classes.jar CMakeFiles/dephelper/opencv_java_android | ${cmake_ninja_workdir}bin/classes.jar ${cmake_ninja_workdir}CMakeFiles/dephelper/opencv_java_android: CUSTOM_COMMAND CMakeFiles/dephelper/opencv_java_android_source_copy android_sdk/build.xml android_sdk/local.properties android_sdk/proguard-project.txt android_sdk/project.properties android_sdk/AndroidManifest.xml || modules/java/android_sdk/opencv_java_android_source_copy modules/java_bindings_generator/gen_opencv_java_source
COMMAND = cmd.exe /C "cd /D D:\OpenCV455\build34\android_sdk && D:\apache-ant-1.9.16\bin\ant.bat -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6 && D:\cmake-3.21.3\bin\cmake.exe -E touch D:/OpenCV455/build34/CMakeFiles/dephelper/opencv_java_android"
DESC = Building OpenCV Android library project
restat = 1
in build.cmake file:
bin/classes.jar: CMakeFiles/dephelper/opencv_java_android_source_copy
bin/classes.jar: android_sdk/build.xml
bin/classes.jar: android_sdk/local.properties
bin/classes.jar: android_sdk/proguard-project.txt
bin/classes.jar: android_sdk/project.properties
bin/classes.jar: android_sdk/AndroidManifest.xml
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=D:\OpenCV455\build41\CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building OpenCV Android library project"
cd /d D:\OpenCV455\build41\android_sdk && call D:\apache-ant-1.9.16\bin\ant.bat -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6
cd /d D:\OpenCV455\build41\android_sdk && D:\cmake-3.21.3\bin\cmake.exe -E touch D:/OpenCV455/build41/CMakeFiles/dephelper/opencv_java_android
CMakeFiles/dephelper/opencv_java_android: bin/classes.jar
in build.xml file:
<do-only-if-manifest-hasCode
elseText="hasCode = false. Skipping aidl/renderscript/R.java">
<echo level="info">Handling aidl files...</echo>
<aidl executable="${aidl}"
framework="${project.target.framework.aidl}"
libraryBinAidlFolderPathRefid="project.library.bin.aidl.folder.path"
genFolder="${gen.absolute.dir}"
aidlOutFolder="${out.aidl.absolute.dir}">
<source path="${source.absolute.dir}"/>
</aidl>
How to fix it?
I try to find solutions for similar problem, and here maybe the only similar one. The developer suggetsted that:
Android SDK: not used, projects are not built
After that message Java-based projects should be skipped completely.
Try to upgrade your Android SDK "BuildTools".
CMAKE_CONFIG_GENERATOR="MinGW Makefiles"
There is ninja build tool in Android NDK. Use cmake -GNinja ... for better experience.
I don't quite grasp how to do, My build tools version is 33.0.0.
I found two options:
shell script (reference)
Install Git Bash and set it in PATH (C:\Program Files\Git\cmd)
Install Cmake 3.24.3 and set it in PATH (C:\Program Files\CMake\bin)
Install java and set it in PATH (C:\Program Files\Java\jdk1.8.0_202\bin), create variable JAVA_HOME(C:\Program Files\Java\jdk1.8.0_202)
Install C compiler (mingw or Visual Studio or etc.). If you use mingw, then you will need to install: mingw32-base-bin,
mingw32-gcc-fortran-bin,
mingw32-gcc-g++-bin,
mingw32-gcc-objc-bin,
msys-base-bin. And then in PATH add C:\MinGW\bin
You may also need WSL for Windows, but I did it just through Git Bash
Create a script in an empty folder and name it build.sh:
#!/bin/bash -e
myRepo=$(pwd)
CMAKE_GENERATOR_OPTIONS=-G"Visual Studio 17 2022"
#CMAKE_GENERATOR_OPTIONS=-G"Visual Studio 15 2017 Win64"
#CMAKE_GENERATOR_OPTIONS=(-G"Visual Studio 16 2019" -A x64) # CMake 3.14+ is required
if [ ! -d "$myRepo/gstreamer" ]; then
echo "cloning gstreamer"
git clone https://github.com/GStreamer/gstreamer.git
else
cd gstreamer
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/openexr" ]; then
echo "cloning openexr"
git clone https://github.com/AcademySoftwareFoundation/openexr.git
else
cd openexr
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/openblas" ]; then
echo "cloning openblas"
git clone https://github.com/xianyi/OpenBLAS.git
else
cd openblas
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/eigen" ]; then
echo "cloning eigen"
git clone https://gitlab.com/libeigen/eigen.git
else
cd eigen
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/opencv" ]; then
echo "cloning opencv"
git clone https://github.com/opencv/opencv.git
else
cd opencv
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/opencv_contrib" ]; then
echo "cloning opencv_contrib"
git clone https://github.com/opencv/opencv_contrib.git
else
cd opencv_contrib
git pull --rebase
cd ..
fi
if [ ! -d "$myRepo/tesseract" ]; then
echo "cloning tesseract"
git clone https://github.com/tesseract-ocr/tesseract.git
else
cd tesseract
git pull --rebase
cd ..
fi
RepoSource=opencv
mkdir -p build_opencv
pushd build_opencv
CMAKE_OPTIONS=( -DBUILD_opencv_world:BOOL=OFF -DBUILD_JAVA:BOOL=ON -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DWITH_CUDA:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DINSTALL_CREATE_DISTRIB=ON)
set -x
cmake "${CMAKE_GENERATOR_OPTIONS[#]}" "${CMAKE_OPTIONS[#]}" -DOPENCV_EXTRA_MODULES_PATH="$myRepo"/opencv_contrib/modules -DCMAKE_INSTALL_PREFIX="$myRepo/install/$RepoSource" "$myRepo/$RepoSource"
echo "************************* $Source_DIR -->debug"
cmake --build . --config debug
echo "************************* $Source_DIR -->release"
cmake --build . --config release
cmake --build . --target install --config release
cmake --build . --target install --config debug
popd
Open Git Bash, open the folder with our script in it and write bash build.sh
If you have following error syntax error: unexpected end of file, then here is the solution
As result we get opencv_java460.dll and opencv-460.jar
Cmake with ninja (taken from here, but modified)
Here I will describe what I used to build (it's not a fact that this is all I need or specific versions, but it worked for me):
Install Python and set it in PATH (C:\Users\volce\AppData\Local\Programs\Python\Python311\Scripts\ и C:\Users\volce\AppData\Local\Programs\Python\Python311\)
Install java 8 and set it in PATH and in JAVA_HOME (see above)
Install Cmake 3.24.3 (I haven't tried it on another version) and set it in PATH (see above)
Download NDK r25, unzip and add an environment variable ANDROID_NDK: C:\Users\volce\AppData\Local\Android\Sdk\ndk\android-ndk-r25b
Download SDK tools r25.2.3, platform-tools r25.0.1 and build-tools r25.0.1
In the SDK folder, replace the contents of the tools, build-tools and platform-tools folders with the downloaded ones
Also, in PATH I added: C:\Users\volce\AppData\Local\Android\Sdk\tools and C:\Users\volce\AppData\Local\Android\Sdk\platform-tools
Adding environment variables: ANDROID_HOME and ANDROID_SDK_ROOT, where we specify the path to the SDK (for example, C:\Users\volce\AppData\Local\Android\Sdk)
Download ant and set it in PATH (C:\apache-ant-1.10.12\bin и C:\apache-ant-1.10.12\lib) and create ANT_HOME (C:\apache-ant-1.10.12)
Download MinGw, install the necessary packages and set it in PATH (see above)
Download and install Visual Studio
What did I do next
Created a folder for our task
In it we do git clone https://github.com/opencv/opencv.git and git clone https://github.com/opencv/opencv_contrib.git
In the folder with opencv, go to samples\android and in the file CMakeLists.txt deleting add_subdirectory(15-puzzle) (because of this, I did not build)
Create a build folder in our root folder (which was created for building opencv)
We go into it and do git clone https://github.com/ninja-build/ninja.git
Open Visual Studio. In it: Tools->Command Line->Developer Command Line. In the command line, write the path to the created folder build and write python configure.py --bootstrap. This is how we configured ninja
Being in our build folder in the console, we write the following(don't forget to change the paths to your own):
cmake -GNinja -DCMAKE_MAKE_PROGRAM=E:\OpenCV\build\ninja.exe -DCMAKE_INSTALL_PREFIX=E:\OpenCV\install -DANDROID_PROJECTS_BUILD_TYPE="ANT" -DBUILD_ANDROID_PROJECTS=ON -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_JAVA=ON -DBUILD_opencv_java=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_FAT_JAVA_LIB=ON -DBUILD_PYTHON:BOOL=OFF -DINSTALL_ANDROID_EXAMPLES:BOOL=OFF -DANDROID_EXAMPLES_WITH_LIBS:BOOL=OFF -DBUILD_DOCS:BOOL=OFF -DWITH_OPENCL=ON -DANDROID_NDK_HOST_X64=ON -DANDROID_NDK=C:/Users/volce/AppData/Local/Android/Sdk/ndk/android-ndk-r25b/ -DANDROID_SDK=C:/Users/volce/AppData/Local/Android/Sdk -DCMAKE_TOOLCHAIN_FILE=C:/Users/volce/AppData/Local/Android/Sdk/ndk/android-ndk-r25b/build/cmake/android.toolchain.cmake -DANDROID_TOOLCHAIN=clang -DANDROID_STL=c++_static -DANDROID_ARM_NEON=ON -DANDROID_ABI='arm64-v8a, armeabi-v7a, x86_64, x86' -DANDROID_NDK_HOST_X64=ON -DBUILD_opencv_python3:BOOL=OFF -DBUILD_opencv_python2:BOOL=OFF -DOPENCV_EXTRA_MODULES_PATH=E:/OpenCV/opencv_contrib/modules -DOPENCV_ENABLE_NONFREE=ON -DANDROID_NATIVE_API_LEVEL=25 -DANDROID_TARGET_SDK_VERSION=32 -DANDROID_MIN_SDK_VERSION=21 E:\OpenCV\opencv
After execution , write ninja -j8 in console
After waiting for the execution of the previous command, we write ninja install
As result we get the OpenCV SDK for Android
How to integrate OpenCV 4.6.0 in your project -> https://www.youtube.com/watch?v=bR7lL886-uc
I have cloned the QtRemoteObjects repository from: http://code.qt.io/cgit/playground/qtremoteobjects.git/
on my Windows 7 using GitBash.exe.
The project files are download to "D:\Daten\Android\qtremoteobjects\". Based on the article on this website: https://www.kdab.com/qt-android-create-android-service-using-qt/ I run this command in GitBash:
$ cd d:/Daten/Android/qtremoteobjects/
$ git c:/Qt5.7.0/5.7/android_armv7/bin/qmake -r && make && make install
QMAKE PART
For the qmake part these errors show up:
Reading D:/Daten/Android/qtremoteobjects/tests/auto/cmake/cmake.pro
Das System kann den angegebenen Pfad nicht finden.
meaning the system could not find the given path. And the next two errors are:
WARNING: Failure to find: rep_server_source.h
Project MESSAGE: cmake executable not found. Not running CMake unit tests
First question: Why doesnt the system find the path for cmake.pro and rep_server_source.h and why isnt the cmake executable not found even though I have separately installed CMake.
MAKE PART
The next error that shows up is:
bash: make: command not found
As a solution to this I separated the qmake and make process. I first just ran qmake
$ git c:/Qt5.7.0/5.7/android_armv7/bin/qmake -r
and when qmake is finished (and the same errors as above still show up) i run mingw32-make.exe from Qt5.7->Tools in the qtremoteobjects folder:
$ c:/Qt5.7.0/Tools/mingw530_32/bin/mingw32-make.exe
and this is the result:
cd src/ && ( test -e Makefile || C:/Qt5.7.0/5.7/android_x86/bin/qmake.exe
D:/Daten/Android/qtremoteobjects/src/src.pro -o Makefile ) && C:/Qt5.7.0/Tools/mingw530_32/bin/mingw32-make -f Makefile
mingw32-make[1]: Entering directory 'D:/Daten/Android/qtremoteobjects/src'
cd remoteobjects/ && ( test -e Makefile || C:/Qt5.7.0/5.7/android_x86/bin/qmake.exe D:/Daten/Android/qtremoteobjects/src/remoteobjects/remoteobjects.pro -o Makefile ) && C:/Qt5.7.0/Tools/mingw530_32/bin/mingw32-make -f Makefile
mingw32-make[2]: Entering directory 'D:/Daten/Android/qtremoteobjects/src/remoteobjects'
D:\Daten\Android\android-ndk-r10e/toolchains/x86-4.9/prebuilt/windows/bin/i686-linux-android-g++ -c -ffunction-sections -funwind-tables -O2 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -DANDROID -Wa,--noexecstack -std=c++11 -mfpmath=sse -O2 -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -Wno-psabi -W -Wvla -D_REENTRANT -fPIC -DQT_NO_XKBCOMMON -DQT_BUILD_REMOTEOBJECTS_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_URL_CAST_FROM_STRING -DQT_BUILD_REMOTEOBJECTS_LIB -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -Ic:/utils/openssl-android-master/include -I../../include -I../../include/QtRemoteObjects -I../../include/QtRemoteObjects/5.6.1 -I../../include/QtRemoteObjects/5.6.1/QtRemoteObjects -I. -IC:/Qt5.7.0/5.7/android_x86/include -IC:/Qt5.7.0/5.7/android_x86/include/QtNetwork -IC:/Qt5.7.0/5.7/android_x86/include/QtCore/5.7.0 -IC:/Qt5.7.0/5.7/android_x86/include/QtCore/5.7.0/QtCore -IC:/Qt5.7.0/5.7/android_x86/include/QtCore -I.moc -isystem D:/Daten/Android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem D:/Daten/Android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -isystem D:/Daten/Android/android-ndk-r10e/platforms/android-9/arch-x86/usr/include -IC:/Qt5.7.0/5.7/android_x86/mkspecs/android-g++ -o .obj/qconnection_local_backend.obj qconnection_local_backend.cpp
Makefile:1720: recipe for target '.obj/qconnection_local_backend.obj' failed
process_begin: CreateProcess(NULL, D:\Daten\Android\android-ndk-r10e/toolchains/x86-4.9/prebuilt/windows/bin/i686-linux-android-g++ -c -ffunction-sections -funwind-tables -O2 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -DANDROID -Wa,--noexecstack -std=c++11 -mfpmath=sse -O2 -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -Wno-psabi -W -Wvla -D_REENTRANT -fPIC -DQT_NO_XKBCOMMON -DQT_BUILD_REMOTEOBJECTS_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_URL_CAST_FROM_STRING -DQT_BUILD_REMOTEOBJECTS_LIB -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -Ic:/utils/openssl-android-master/include -I../../include -I../../include/QtRemoteObjects -I../../include/QtRemoteObjects/5.6.1 -I../../include/QtRemoteObjects/5.6.1/QtRemoteObjects -I. -IC:/Qt5.7.0/5.7/android_x86/include -IC:/Qt5.7.0/5.7/android_x86/include/QtNetwork -IC:/Qt5.7.0/5.7/android_x86/include/QtCore/5.7.0 -IC:/Qt5.7.0/5.7/android_x86/include/QtCore/5.7.0/QtCore -IC:/Qt5.7.0/5.7/android_x86/include/QtCore -I.moc -isystem D:/Daten/Android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem D:/Daten/Android/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -isystem D:/Daten/Android/android-ndk-r10e/platforms/android-9/arch-x86/usr/include -IC:/Qt5.7.0/5.7/android_x86/mkspecs/android-g++ -o .obj/qconnection_local_backend.obj qconnection_local_backend.cpp, ...) failed.
make (e=2): Das System kann die angegebene Datei nicht finden.
mingw32-make[2]: *** [.obj/qconnection_local_backend.obj] Error 2
mingw32-make[2]: Leaving directory 'D:/Daten/Android/qtremoteobjects/src/remoteobjects'
Makefile:44: recipe for target 'sub-remoteobjects-make_first-ordered' failed
mingw32-make[1]: *** [sub-remoteobjects-make_first-ordered] Error 2
mingw32-make[1]: Leaving directory 'D:/Daten/Android/qtremoteobjects/src'
Makefile:46: recipe for target 'sub-src-make_first' failed
mingw32-make: *** [sub-src-make_first] Error 2
Second Question Why is make not successful here? what do these errors mean? What is wrong with '.obj/qconnection_local_backend.obj'
Is it because I am running make on Windows?
Thanks,
I'm trying to compile openssl-1.1.0 on Android by cygwin follow by this guidance:
Compiling the latest OpenSSL for Android
But it's failed, this is the error :
crypto/aes/aes_ecb.c:10:20: fatal error: assert.h: No such file or directory
#include <assert.h>
I'm using Android-ndk-r12b, Win10, cygwin 64 bit.
This is my pre-config before compiling:
export NDK=~/android-ndk-r12b
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-21 --toolchain=arm-linux-androideabi-4.9 --install-dir=`pwd`/android-toolchain-arm
export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm/bin
export TOOL=arm-linux-androideabi
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
export LINK=${CXX}
export LD=$NDK_TOOLCHAIN_BASENAME-ld
export AR=$NDK_TOOLCHAIN_BASENAME-ar
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
export ARCH_FLAGS="-mthumb"
export ARCH_LINK=
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
export LDFLAGS=" ${ARCH_LINK} "
./Configure android
PATH=$TOOLCHAIN_PATH:$PATH make
Please help to tell me where I'm wrong
EDIT:
Follow by jww's suggestion, I try with https://wiki.openssl.org/index.php/Android
I changed some config in setenv-android.sh into:
-_ANDROID_NDK="android-ndk-r12b"
-_ANDROID_EABI="arm-linux-androideabi-4.9"
-_ANDROID_API="android-21"
To generate valid toolchains, I add "windows-x86_64" into
for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86"
Now it's:
for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86" "windows-x86_64"
do
....
done
+Build openssl-1.1.0:
Error:
$ perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
Can't open Makefile.org: No such file or directory.
EDIT 2:
I follow the wiki update by jww and it runs smoothly until this command:
arm-linux-androideabi-gcc -I /usr/local/ssl/include my_prog.c -o my_prog.exe -L /usr/local/ssl/lib -lssl -lcrypto
If I use $ANDROID_TOOCHAIN/arm-linux-androideabi-gcc -I /usr/local/ssl/include my_prog.c -o my_prog.exe -L /usr/local/ssl/lib -lssl -lcrypto , it doesn't understand -I and my_prog.c
I want to build openssl-1.1.0 for android but I don't know how to fix it. Please help
I was trying to build OpenSSL 1.1.0g for Android with
android NDK android-ndk-r16b, centOS 6.9 64 bit OS.
as per https://wiki.openssl.org/index.php/Android
and had the same problem
crypto/aes/aes_ecb.c:10:20: fatal error: assert.h: No such file or directory
#include <assert.h>
After searching, I found that Updated NDK android-ndk-r16b has updated the sysroot to android-ndk-r16b/sysroot which contains the include directories but no library.
So the include path and the library path has changed
but the setenv-android.sh set the sysroot as
export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
But this is valid for android-ndk-r13b
I can successfully build the OpenSSL with android-ndk-r13b.
Please take a look at this Github library
setenv-android.sh is not necessary. This really works.
I'm currently trying to compile the libtorrent source files with Python bindings for Android. To do this, I have my custom toolchain with a compiled Boost library.
I use the following command to configure the libtorrent installation:
./configure --host=$CROSSHOST --prefix=$CROSSHOME --with-boost=$CROSSHOME --with-boost-libdir=$CROSSHOME/lib --enable-static --disable-shared --enable-debug --enable-logging --enable-python-binding
The variables are setup as follow:
export ANDROIDNDK='/home/martijn/Documenten/android-ndk-r9d'
export SYSROOT=$ANDROIDNDK/platforms/android-14/arch-arm
export PYTHON=/home/martijn/Documenten/python-for-android/build/python/Python-2.7.2/hostpython
export PYTHON_CPP_FLAGS="-I/home/martijn/Documenten/python-for-android/build/python/Python-2.7.2 -I/home/martijn/Documenten/python-for-android/build/python/Python-2.7.2/Include"
# Custom ARM toolchain
export SYSROOT=$ANDROIDNDK/platforms/android-14/arch-arm
export PATH=/usr/local/gcc-4.8.0-arm-linux-androideabi/bin:$PATH
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
export CROSSHOST=arm-linux-androideabi
export CROSSHOME=/usr/local/gcc-4.8.0-arm-linux-androideabi
# Set ARM v5 architecture with debug flag!
export CFLAGS="-g"
export CXXFLAGS=$CLFAGS
Compiling without the --enable-python-binding flag gives no problem and I correctly get a libtorrent.so file. At the end of the compilation, I get the following error:
creating build/lib.linux-x86_64-2.7
arm-linux-androideabi-g++ arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/martijn/Documenten/android-ndk-r9d/platforms/android-14/arch-arm -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -shared -lm -L/home/martijn/Documenten/python-for-android/build/openssl/openssl-1.0.1g/ -g -fvisibility=hidden build/temp.linux-x86_64-2.7/src/alert.o build/temp.linux-x86_64-2.7/src/error_code.o build/temp.linux-x86_64-2.7/src/module.o build/temp.linux-x86_64-2.7/src/datetime.o build/temp.linux-x86_64-2.7/src/fingerprint.o build/temp.linux-x86_64-2.7/src/entry.o build/temp.linux-x86_64-2.7/src/session.o build/temp.linux-x86_64-2.7/src/torrent_info.o build/temp.linux-x86_64-2.7/src/magnet_uri.o build/temp.linux-x86_64-2.7/src/converters.o build/temp.linux-x86_64-2.7/src/string.o build/temp.linux-x86_64-2.7/src/utility.o build/temp.linux-x86_64-2.7/src/session_settings.o build/temp.linux-x86_64-2.7/src/create_torrent.o build/temp.linux-x86_64-2.7/src/big_number.o build/temp.linux-x86_64-2.7/src/torrent_handle.o build/temp.linux-x86_64-2.7/src/torrent_status.o build/temp.linux-x86_64-2.7/src/version.o build/temp.linux-x86_64-2.7/src/ip_filter.o build/temp.linux-x86_64-2.7/src/peer_info.o -L../../src/.libs -L/usr/local/ssl/lib -L. -ltorrent-rasterbar -lboost_system -lboost_python -lssl -lcrypto -lpython2.7 -o build/lib.linux-x86_64-2.7/libtorrent.so -L/usr/local/gcc-4.8.0-arm-linux-androideabi/lib
arm-linux-androideabi-g++: error: arm-linux-androideabi-gcc: No such file or directory
error: command 'arm-linux-androideabi-g++' failed with exit status 1
I'm not sure what's causing this error. I think have I my arm-linux-androieabi-g++ command setup correctly but maybe there's a setting that I oversee. Anyone here who can help me?
I'm on Fedora Linux 19, using the latest Android SDK, latest java SDK, and NDK=R9. Using the instructions here, I'm trying to create a python/kivy installation specialized for android, by running the command, ./distribute.sh -m "kivy". It produces the output below. Can anyone tell me what's going wrong here, and what I can do to fix it? Thank you.
./dist*sh -m "kivy"
Check build dependencies for Fedora
Avoid check build dependencies, unknow platform Fedora
Check enviromnent
SDK located at /home/ljm/Developer/android-sdks
NDK located at /home/ljm/Developer/android-ndk-r9
NDK version is r9
API level set to 18
Check mandatory tools
Distribution will be located at /home/ljm/Developer/workspace/python-for-android/dist/default
The distribution /home/ljm/Developer/workspace/python-for-android/dist/default already exist
Press a key to remove it, or Control + C to abort.
Entering in ARM enviromnent
Compiler found at /home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
PATH is /home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/:/home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86_64/bin/:/home/ljm/Developer/android-ndk-r9:/home/ljm/Developer/android-sdks/tools:/home/ljm/Developer/android-ndk-r9:/home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/:/home/ljm/Developer/android-sdks:/home/ljm/Developer/android-sdks/platform-tools:/home/ljm/Developer/android-sdks/tools:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/usr/sbin:/homeljm.local/bin:/homeljmbin
Leaving ARM enviromnent
Read kivy recipe
Module kivy depend on pygame pyjnius android
Read pygame recipe
Module pygame depend on python sdl
Read pyjnius recipe
Module pyjnius depend on python sdl
Read android recipe
Module android depend on pygame
Read python recipe
Module python depend on hostpython
Read sdl recipe
Module sdl depend on python
Ignored python, already processed
Ignored sdl, already processed
Ignored pygame, already processed
Read hostpython recipe
Ignored python, already processed
Modules changed to hostpython python sdl pygame pyjnius android kivy
Run get packages
Download package for hostpython
Module hostpython already downloaded
Download package for python
Module python already downloaded
Download package for sdl
No package for sdl
Download package for pygame
Module pygame already downloaded
Download package for pyjnius
Module pyjnius already downloaded
Download package for android
No package for android
Download package for kivy
Module kivy already downloaded
Run prebuild
Call prebuild_hostpython
Call prebuild_python
Call prebuild_sdl
Call prebuild_pygame
Call prebuild_pyjnius
Call prebuild_android
Call prebuild_kivy
Run build
Call build_hostpython
Call build_python
Call build_sdl
Entering in ARM enviromnent
Compiler found at /home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
Android NDK: WARNING:/home/ljm/Developer/workspace/python-for-android/src/jni/../jni/application/Android.mk:application: non-system libraries in linker flags: -lpython2.7
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: WARNING:/home/ljm/Developer/workspace/python-for-android/src/jni/../jni/png/Android.mk:png: LOCAL_LDLIBS is always ignored for static libraries
rm -f /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/lib*.so /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi-v7a/lib*.so /home/ljm/Developer/workspace/python-for-android/src/libs/mips/lib*.so /home/ljm/Developer/workspace/python-for-android/src/libs/x86/lib*.so
rm -f /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/gdbserver /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi-v7a/gdbserver /home/ljm/Developer/workspace/python-for-android/src/libs/mips/gdbserver /home/ljm/Developer/workspace/python-for-android/src/libs/x86/gdbserver
rm -f /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/gdb.setup /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi-v7a/gdb.setup /home/ljm/Developer/workspace/python-for-android/src/libs/mips/gdb.setup /home/ljm/Developer/workspace/python-for-android/src/libs/x86/gdb.setup
Install : libapplication.so => libs/armeabi/libapplication.so
install -p /home/ljm/Developer/workspace/python-for-android/src/obj/local/armeabi/libapplication.so /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libapplication.so
/home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --strip-unneeded /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libapplication.so
Install : libsdl.so => libs/armeabi/libsdl.so
install -p /home/ljm/Developer/workspace/python-for-android/src/obj/local/armeabi/libsdl.so /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl.so
/home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --strip-unneeded /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl.so
Install : libsdl_main.so => libs/armeabi/libsdl_main.so
install -p /home/ljm/Developer/workspace/python-for-android/src/obj/local/armeabi/libsdl_main.so /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl_main.so
/home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --strip-unneeded /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl_main.so
Install : libsdl_ttf.so => libs/armeabi/libsdl_ttf.so
install -p /home/ljm/Developer/workspace/python-for-android/src/obj/local/armeabi/libsdl_ttf.so /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl_ttf.so
/home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --strip-unneeded /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl_ttf.so
Install : libsdl_image.so => libs/armeabi/libsdl_image.so
install -p /home/ljm/Developer/workspace/python-for-android/src/obj/local/armeabi/libsdl_image.so /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl_image.so
/home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --strip-unneeded /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl_image.so
Install : libsqlite3.so => libs/armeabi/libsqlite3.so
install -p /home/ljm/Developer/workspace/python-for-android/src/obj/local/armeabi/libsqlite3.so /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsqlite3.so
/home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --strip-unneeded /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsqlite3.so
Install : libsdl_mixer.so => libs/armeabi/libsdl_mixer.so
install -p /home/ljm/Developer/workspace/python-for-android/src/obj/local/armeabi/libsdl_mixer.so /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl_mixer.so
/home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --strip-unneeded /home/ljm/Developer/workspace/python-for-android/src/libs/armeabi/libsdl_mixer.so
Leaving ARM enviromnent
Call build_pygame
Entering in ARM enviromnent
Compiler found at /home/ljm/Developer/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
running install
running build
running build_py
running build_ext
building 'pygame.surface' extension
arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/ljm/Developer/android-ndk-r9/platforms/android-18/arch-arm -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/ljm/Developer/android-ndk-r9/platforms/android-18/arch-arm -I/home/ljm/Developer/workspace/python-for-android/src/jni/png -I/home/ljm/Developer/workspace/python-for-android/src/jni/jpeg -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl/include -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_mixer -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_ttf -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_image -fPIC -D_REENTRANT -I/home/ljm/Developer/workspace/python-for-android/build/python-install/include/python2.7 -c src/surface.c -o build/temp.linux-i686-2.7/src/surface.o
In file included from /home/ljm/Developer/workspace/python-for-android/build/python-install/include/python2.7/Python.h:126:0,
from src/pygame.h:75,
from src/surface.h:28,
from src/surface.c:26:
/home/ljm/Developer/workspace/python-for-android/build/python-install/include/python2.7/modsupport.h:27:1: warning: 'PyArg_ParseTuple' is an unrecognized format function type [-Wformat=]
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);
^
src/surface.c: In function 'surf_get_locked':
src/surface.c:755:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
Py_RETURN_TRUE;
^
src/surface.c:756:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
Py_RETURN_FALSE;
^
src/surface.c: In function 'surf_convert_alpha':
src/surface.c:1279:28: warning: variable 'src' set but not used [-Wunused-but-set-variable]
SDL_Surface *newsurf, *src;
^
arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/ljm/Developer/android-ndk-r9/platforms/android-18/arch-arm -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/ljm/Developer/android-ndk-r9/platforms/android-18/arch-arm -I/home/ljm/Developer/workspace/python-for-android/src/jni/png -I/home/ljm/Developer/workspace/python-for-android/src/jni/jpeg -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl/include -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_mixer -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_ttf -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_image -fPIC -D_REENTRANT -I/home/ljm/Developer/workspace/python-for-android/build/python-install/include/python2.7 -c src/alphablit.c -o build/temp.linux-i686-2.7/src/alphablit.o
In file included from /home/ljm/Developer/workspace/python-for-android/build/python-install/include/python2.7/Python.h:126:0,
from src/pygame.h:75,
from src/surface.h:28,
from src/alphablit.c:25:
/home/ljm/Developer/workspace/python-for-android/build/python-install/include/python2.7/modsupport.h:27:1: warning: 'PyArg_ParseTuple' is an unrecognized format function type [-Wformat=]
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);
^
In file included from src/surface.h:28:0,
from src/alphablit.c:25:
src/pygame.h:678:14: warning: 'PyGAME_C_API' defined but not used [-Wunused-variable]
static void* PyGAME_C_API[PYGAMEAPI_TOTALSLOTS] = { NULL };
^
arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/ljm/Developer/android-ndk-r9/platforms/android-18/arch-arm -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/ljm/Developer/android-ndk-r9/platforms/android-18/arch-arm -I/home/ljm/Developer/workspace/python-for-android/src/jni/png -I/home/ljm/Developer/workspace/python-for-android/src/jni/jpeg -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl/include -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_mixer -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_ttf -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_image -fPIC -D_REENTRANT -I/home/ljm/Developer/workspace/python-for-android/build/python-install/include/python2.7 -c src/surface_fill.c -o build/temp.linux-i686-2.7/src/surface_fill.o
In file included from /home/ljm/Developer/workspace/python-for-android/build/python-install/include/python2.7/Python.h:126:0,
from src/pygame.h:75,
from src/surface.h:28,
from src/surface_fill.c:20:
/home/ljm/Developer/workspace/python-for-android/build/python-install/include/python2.7/modsupport.h:27:1: warning: 'PyArg_ParseTuple' is an unrecognized format function type [-Wformat=]
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);
^
In file included from src/surface.h:28:0,
from src/surface_fill.c:20:
src/pygame.h:678:14: warning: 'PyGAME_C_API' defined but not used [-Wunused-variable]
static void* PyGAME_C_API[PYGAMEAPI_TOTALSLOTS] = { NULL };
^
/home/ljm/Developer/workspace/python-for-android/src/tools/liblink -lm -L/home/ljm/Developer/workspace/python-for-android/build/libs -L/home/ljm/Developer/workspace/python-for-android/src/obj/local/armeabi/ -lm -lz -DANDROID -mandroid -fomit-frame-pointer --sysroot /home/ljm/Developer/android-ndk-r9/platforms/android-18/arch-arm -I/home/ljm/Developer/workspace/python-for-android/src/jni/png -I/home/ljm/Developer/workspace/python-for-android/src/jni/jpeg -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl/include -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_mixer -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_ttf -I/home/ljm/Developer/workspace/python-for-android/src/jni/sdl_image build/temp.linux-i686-2.7/src/surface.o build/temp.linux-i686-2.7/src/alphablit.o build/temp.linux-i686-2.7/src/surface_fill.o -L/home/ljm/Developer/workspace/python-for-android/build/python-install/lib -lsdl -lm -lpython2.7 -o build/lib.linux-i686-2.7/pygame/surface.so
arm-linux-androideabi-ld: -arch: unknown option
arm-linux-androideabi-ld: use the --help option for usage information
error: command '/home/ljm/Developer/workspace/python-for-android/src/tools/liblink' failed with exit status 1
In accordance with the above suggestion of downgrading the API and NDK (to 14 and r8c, respectively), I've downgraded the android tools, and the problem seems to have been resolved. Thanks!