Android NDK openssl compiler error

I tried to make a simple test program with AES decryption using Android-OpenSSLibraries. The compiler / linker is showing me an error. Compiler:

error: undefined reference to 'AES_set_encrypt_key'
error: undefined reference to 'AES_encrypt'
error: undefined reference to 'AES_set_decrypt_key'

      

And this is my Android.mk file,

LOCAL_PATH := $(call my-dir)
$(info $(LOCAL_PATH))
include $(CLEAR_VARS)

LOCAL_MODULE := demo
LOCAL_CFLAGS := -I/some/include/path
LOCAL_LDLIBS := \
        -llog \
        -lz \
        -lm \

LOCAL_SRC_FILES := \
       aes_api.c \
        io_module.cpp \
        jni_native.cpp \
        JniConstants.cpp \
        JNIHelp.cpp \
        libcrypto.so \
    PosixFile.cpp \

LOCAL_C_INCLUDES := \
    $(LOCAL_PATH)/include \
    $(LOCAL_PATH)/include/openssl
$(info  $(LOCAL_C_INCLUDES))

LOCAL_SHARED_LIBRARIES := \
        $(LOCAL_PATH)/libcrypto.so

include $(BUILD_SHARED_LIBRARY)

      

+3


source to share


1 answer


Invalid content LOCAL_SHARED_LIBRARIES

. You must specify modules for it, not paths to shared objects.

Before defining this variable, there should be the following:

include $(CLEAR_VARS)

#Name it as you want, it doesn't matter. For consistency, let name it LibCrypto
LOCAL_MODULE := LibCrypto 
LOCAL_EXPORT_C_INCLUDES := <path/to/Libcrypto/includes>
LOCAL_SRC_FILES := <path/to/libCrypto/shared/object>/libcrypto.so

include $(PREBUILT_SHARED_LIBRARY)

      

and then in LOCAL_SHARED_LIBRARIES

you link to it directly with its module name:



LOCAL_SHARED_LIBRARIES := LibCrypto

      

Note that you can add another lib by specifying other such "modules" that you can even create (using include $(BUILD_SHARED_LIBRARY)

) beforehand and then reference multiple modules like this:

LOCAL_SHARED_LIBRARIES := module1 \
                          module2 \
                          ...

      

I highly recommend you visit and save this link to the Android.mk spec

+1


source







All Articles