When I call ndk-build I got some "undefined reference to" errors. I have been trying to fix a couple of days but unfortunately I was not successful.
It sounds like AES_encrypt
is not you only error. For AES_encrypt
, here's where its located:
$ grep -R AES_encrypt *
crypto/aes/aes.h:void AES_encrypt(const unsigned char *in, unsigned char *out,
...
crypto/aes/aes_core.c:void AES_encrypt(const unsigned char *in, unsigned char *out,
...
I don't use the NDK build system, so I'm not sure if aes_core.c
is actually being compiled from your example.
However, you do have LOCAL_STATIC_LIBRARIES += crypto
, and you can verify the function is present in the archive with the NDK's version of nm
(I believe its arm-linux-androideabi-nm
) as follows. You want to see an entry with a T
(T
is a definition in the Text section):
$ nm libcrypto.a | grep -i AES_encrypt
...
U AES_encrypt
0000000000000460 T AES_encrypt
0000000000000000 t _x86_64_AES_encrypt
00000000000001f0 t _x86_64_AES_encrypt_compact
...
If you are still having trouble, OpenSSL offers direction for building the library from the command line outside of the NDK build system. See FIPS Library and Android (and skip the FIPS part). From Build the FIPS Capable Library:
# From the 'root' directory
$ . ./setenv-android.sh
$ cd openssl-1.0.1e/
$ ./config shared no-ssl2 no-comp no-hw no-engine \
--openssldir=/usr/local/ssl/$ANDROID_API
$ make depend
$ make all
$ sudo -E make install \
CC=$ANDROID_TOOLCHAIN/arm-linux-androideabi-gcc \
RANLIB=$ANDROID_TOOLCHAIN/arm-linux-androideabi-ranlib
In the recipe above, ANDROID_TOOLCHAIN
is set by the setenv-android.sh
script.
Also, you can usually find something prebuilt on Github. http://www.google.com/search?q=openssl+android+site:github.com