Issues building for android
Hello.
We are a group of students attempting to use OpenABE for a team project, requiring us to build the project for Linux as well as Android.
Following your build instructions, we were able to build the project for Linux without too many problems, the test examples appear to work properly. 2 small issues we encountered:
- Makefile.common has cc=g++, causing an error, fixed by setting it to gcc.
- download_gtest.sh occasionally fails downloading, fixed by adding --no-check-certificate to the wgets call.
Building it for android proved to be much more difficult, we ran into various issues with the android.sh script, many of which we were able to fix (we think), by changing the script or the environment variables. Details below.
Currently, the script appears to install the requirements properly, but when making the project via make src, many required header files seem to be missing or in incorrect locations. This might very well be caused by our modifications. Error message: "/(home)/openabe/root/include/openabe/zml/zelement.h:47:11: fatal error: relic/relic.h: No such file or directory #include <relic/relic.h> " Adding an include for the correct location of the relic.h or copying it to an already included location causes hundreds of similar error messages for all kinds of header files.
We are unsure what causes this issue and how to fix it. The requirements might not be installed properly, maybe caused by our modifications. The linker might not properly link the libraries. Or maybe we're just missing some includes. Any insight you could provide would be helpful.
If we instead first attempt to build the project for Linux within the same folder, the headers do exist at the correct locations. If we now perform the build process for android again in the same folder, make src builds the project, and the tests work. However, we are not sure if we did build the project for android at that point, or some sort of bastardized Linux version. Or are you supposed to build the project for Linux first, before you even start to build it for android? This would fix some of the issues with the build process for android we encountered. We did not test this version on an actual android system.
Specifications: Ubuntu 18.04.2 Android NDK r10e GMP 6.0.0 Relic toolkit 0.5.0 OpenSSL 1.1.1 gtest 1.8.0 target arch: armv7-a
Modifications to the android.sh and the build process in general:
- android.sh doesn't automatically download OpenSSL, Relic or gtest, so perform their download scripts first.
- android.sh uses environment variables setup in your env file, so we setup the environment before starting android.sh
- we run android.sh using clang. gcc produced various issues, especially with relic. However clang didn't work with OpenSSL, so:
OpenSSL:
- we build OpenSSL by itself before running the android.sh script using gcc. We were unable to build it with clang.
- Run Configure android-arm instead of just android. android by itself doesn't seem to be a valid option.
- additional flags for OpenSSL Configure: -latomic -march=armv7-a -mthumb -Dchar16_t=uint16_t -Dchar32_t=uint32_t we were getting compiler errors about atomic library calls, requiring thumb2 instructions, and some custom variable types to not exist. Running configure with these flags fixed the issues.
android.sh:
- changed lib versions as instructed
- skip OpenSSL building, since we did that seperately
- line 116: RANLIB="/bin/true" to RANLIB="$TOOLCHAIN_ARCH-ranlib"
- line 197 and 207: -DWORD to -DWSIZE (Relic replaced WORD with WSIZE)
- gtest: modified generated Android.mk file, it didn't seem to use the correct folder structure and includes starting line 269: echo " LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_CPP_EXTENSION := .cc LOCAL_MODULE := libgtest LOCAL_C_INCLUDES := $(LOCAL_PATH)/../googletest/include . $(LOCAL_PATH)/../googletest/ . LOCAL_SRC_FILES := ../googletest/src/gtest-all.cc include $(BUILD_SHARED_LIBRARY) " > ./jni/Android.mk
Any help would be greatly appreciated.