Take the 2-minute tour ×

I use this AES library (in C language),

I follow this page and use the commds mentioned to compile libaes.a,

gcc -c -O2 -fomit-frame-pointer aescrypt.c aeskey.c aestab.c aes_modes.c
ar rcs libaes.a *.o

I can compile and run my program using the libaes.a without problem.

However if use ndk-build to compile my program (indeed modified a little),
I always get this error message and fail to compile...

"...member aes_modes.o in archive is not an object..."

what's wrong with that file?
Or what's wrong with the process?

my Android.mk :

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := libaes
LOCAL_SRC_FILES := libaes.a
include $(CLEAR_VARS)
LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.c
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog

share|improve this question
my computer is "Windows 7, 64bit". Does that have something to do with my problem? –  user538565 Oct 30 '11 at 8:55
add comment

1 Answer

up vote 1 down vote accepted

I've a feeling that you compiled aes with native tools (x86) and using it as prebuild library. I've tried this Android.mk and it works:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := aes
LOCAL_SRC_FILES := aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c


include $(CLEAR_VARS)

LOCAL_C_INCLUDES        := jni/aes
LOCAL_MODULE            := hello-jni
LOCAL_SRC_FILES         := hello-jni.c


Just unzip aes-src-16-04-07.zip into jni/aes. I think it is better to use ndk build system because it can set all necesary options.

And hello-jni.c (just in case):

#include <aes.h>

void test() {
share|improve this answer
It works. Thanks. But still got a problem. I compiled my program with cygwin and encrypted files on PC (Windows 7, 64bit). Then I push the encrypted files onto SDcard, decrypted them on Android. Unfortunately the decrypted file wasn't readable, the same problem as this thread: stackoverflow.com/questions/7937715/android-aes-in-c why? –  user538565 Oct 30 '11 at 11:57
Is uint_8t the same on PC and Android ? –  user538565 Oct 30 '11 at 12:02
The first though was - maybe it is the endianness problem? If it so, try to switch bytes in the word. –  m039 Oct 30 '11 at 12:07
add comment

Your Answer


