androidstagefright

Android: error: undefined reference to 'android_atomic_dec'


I am trying to build my code for h.264 video decoding using hardware decoder(OMX codec) in native code of android 4.0.4 by keeping it in the android source tree. The android source is already built. I am using mm command to build my decoder module.
But when I try to build it I am getting the following error

prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld:   
out/target/product/generic/obj/SHARED_LIBRARIES/custom_decoder_intermediates/custom_decoder.o:
in function custom_decoder::decode_video():frameworks/base/include/utils/RefBase.h:171:  
error: undefined reference to 'android_atomic_dec'

when I explored about it, came to know that android_atomic_dec is defined in cutils/atomic.h which is in system/core/libcutils and the header at system/core/include/cutils of AOSP 4.0.4.
So I have added this also in my android.mk via LOCAL_C_INCLUDES but still to get the same error.
Can someone help me to solve this ??....


Solution

  • You must add cutils to the linkage stage:

    LOCAL_LDLIBS += -L $(path-to-system-libs) -lcutils
    

    If you are building AOSP tree, use instead the following:

    LOCAL_SHARED_LIBRARIES += libcutils