0
votes

I am facing the following issue when trying to compile a c program using openssl for android x-86. I set up the environment variables as follows using the following script:

setenv-android.sh

After running the script I have the following environment.

./setenv-android_x86.sh 
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
Error: FIPS_SIG does not specify incore module. Please edit this script.
ANDROID_NDK_ROOT: /opt/android-ndk-r9d-x86
ANDROID_ARCH: arch-x86
ANDROID_EABI: x86-4.6
ANDROID_API: android-18
ANDROID_SYSROOT: /opt/android-ndk-r9d-x86/platforms/android-18/arch-x86
ANDROID_TOOLCHAIN: /opt/android-ndk-r9d-x86/toolchains/x86-4.6/prebuilt/darwin-x86_64/bin
FIPS_SIG: 
CROSS_COMPILE: i686-linux-android-
ANDROID_DEV: /opt/android-ndk-r9d-x86/platforms/android-18/arch-x86/usr

However when trying to compile with the following command I get the following error:

pwd /opt/android-ndk-r9d-x86/bin

./i686-linux-android-gcc Test.c -o test -lcrypto 

fatal error: openssl/conf.h: No such file or directory

When I locate for the openssl/conf.h I see the file is available in many places:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/openssl/conf.h /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/openssl/conf.h /data/local/arm/ssl/include/openssl/conf.h /data/local/ssl/include/openssl/conf.h /openssl/include/openssl/conf.h /openssl-1.0.1e/include/openssl/conf.h /openssl-1.0.1g/include/openssl/conf.h /opt/local/include/openssl/conf.h /usr/include/openssl/conf.h /usr/local/include/openssl/conf.h /usr/local/ssl/android-14/include/openssl/conf.h /usr/local/ssl/android-18/include/openssl/conf.h
/usr/local/ssl/android-18-x86/include/openssl/conf.h /usr/local/ssl/include/openssl/conf.h

I think the proper path is this:
/usr/local/ssl/android-18-x86/include/openssl/conf.h
I tried with the -L option but with no luck.
-L/usr/local/ssl/android-18-x86/include/

Can anybody please explain how to setup the path properly to solve this issue. (finally there is no issue with the C code as it compiles properly with gcc)

1
Have you tried "-I/usr/local/ssl/android-18-x86/include/"? -L is for adding a directory to the library search path, -I (uppercase i) is for adding a directory to the include search path.Maik
I tried it now, -I did not work. Though it gave more errors than before...user340

1 Answers

1
votes

You are compiling your code using the Android NDK, which creates a "virtual" compiling environment by placing everything you need to compile for android into the ${ANDROID_SYSROOT} directory.

Those directories you listed are outside that sysroot, and therefore are not available to the build system, hence the errors. You must install OpenSSL for Android and putting the resulting headers and binaries there. You might follow this guide to assist you in that.