I'm trying to build openh264 to use on android
-I've the latest openh264 source from git
-I've ndk 17
-I'm using ubuntu 16.04
running
make OS=android NDKROOT=/home/r/aff/ndk TARGET=android-27 NDKLEVEL=27 sysroot=/home/r/aff/ndk/sysroot
I get the error:
r#r:~/aff/openh264$ make OS=android NDKROOT=/home/r/aff/ndk TARGET=android-27 NDKLEVEL=27 sysroot=/home/r/aff/ndk/sysroot/home/r/aff/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -O3 -DNDEBUG -DHAVE_NEON -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -DANDROID_NDK -fpic --sysroot=/home/r/aff/ndk/platforms/android-27/arch-arm -MMD -MP -DGENERATED_VERSION_HEADER -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc -I/home/r/aff/ndk/sysroot -Dandroid_getCpuIdArm=wels_getCpuIdArm -Dandroid_setCpuArm=wels_setCpuArm -Dandroid_getCpuCount=wels_getCpuCount -Dandroid_getCpuFamily=wels_getCpuFamily -Dandroid_getCpuFeatures=wels_getCpuFeatures -Dandroid_setCpu=wels_setCpu -I/home/r/aff/ndk/sources/android/cpufeatures -c -o codec/common/src/cpu-features.o /home/r/aff/ndk/sources/android/cpufeatures/cpu-features.c
In file included from /home/r/aff/ndk/sources/android/cpufeatures/cpu-features.c:64:0:
/home/r/aff/ndk/sources/android/cpufeatures/cpu-features.h:31:23: fatal error: sys/cdefs.h: No such file or directory
#include <sys/cdefs.h>
^
compilation terminated.
build/platform-android.mk:96: recipe for target 'codec/common/src/cpu-features.o' failed
make: *** [codec/common/src/cpu-features.o] Error 1
When in doubt, stop rolling your own build configurations and use a standalone toolchain (pay particular attention to the section at the bottom about "Building open source projects using standalone toolchains": https://developer.android.com/ndk/guides/standalone_toolchain
Changing from
TARGET=android-27 NDKLEVEL=27
to
TARGET=android-21 NDKLEVEL=21
solved this issue for me.
I'm building parquet-cpp project on Ubuntu for Android using cmake 3.10 (by following tutorials "Cross Compiling for Android with a Standalone Toolchain" in this link). I got this error:
In file included from /usr/include/errno.h:28:
/usr/include/features.h:391:10: fatal error: 'gnu/stubs.h' file not found
#include <gnu/stubs.h>
I checked compiling command and found an argument -isystem /usr/include. I tried to exclude /usr/include from search paths but I failed. This is the full command:
<standalone_toolchain>/bin/clang++ --target=armv7-none-linux-androideabi --gcc-toolchain=<standalone_toolchain> --sysroot=<standalone_toolchain>/sysroot -DBOOST_ALL_DYN_LINK -DBOOST_TEST_DYN_LINK -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Dthriftz_EXPORTS -I<source_dir>/parquet-cpp/build/thrift_ep-prefix/src/thrift_ep-build/lib/cpp -I<source_dir>/parquet-cpp/build/thrift_ep-prefix/src/thrift_ep/lib/cpp -I<source_dir>/parquet-cpp/build/thrift_ep-prefix/src/thrift_ep-build -I<source_dir>/parquet-cpp/build/thrift_ep-prefix/src/thrift_ep/lib/cpp/src -isystem /usr/include -isystem <standalone_toolchain>/sysroot/usr/include -isystem <standalone_toolchain>/include/c++/4.9.x -isystem <standalone_toolchain>/include/c++/4.9.x/arm-linux-androideabi/bits -march=armv7-a -marm -mfpu=neon -mfloat-abi=softfp -funwind-tables -no-canonical-prefixes --sysroot <standalone_toolchain>/sysroot -Qunused-arguments -ggdb -O0 -g -fPIC -Wno-variadic-macros -Wno-long-long -Wno-c++11-long-long -Wno-deprecated-register -pthread -g -fPIC -std=c++11 -o CMakeFiles/thriftz.dir/src/thrift/transport/TZlibTransport.cpp.o -c <source_dir>/parquet-cpp/build/thrift_ep-prefix/src/thrift_ep/lib/cpp/src/thrift/transport/TZlibTransport.cpp
I've tried lots of ways I found out when googling (i.e. here and here) but nothing works.
Can anyone here help me? Note that I'm a newbie to cross compiling :(
if you mean by exclude is to delete:
then type this in the terminal --> sudo gksu nautilus a new file manager window will open were you can access all files as root, now reach you file then delete it.
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!
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