Search code examples
c++android-ndkjava-native-interface

NDK: has not been declared


I am compiling the C++ code using Android native library NDK but I am getting the following errors while trying to include the g729a.h file in g729_jni.cpp:

ERRORS:

Compile++ arm    : g729_jni <= g729_jni.cpp
/usr/src/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs/g729_jni/g729_jni.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -O2 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -I/usr/src/android-ndk-r8/sources/cxx-stl/system/include -Ijni -DANDROID -O3 -Wa,--noexecstack   -O2 -DNDEBUG -g   -I/usr/src/android-ndk-r8/platforms/android-3/arch-arm/usr/include -c  jni/g729_jni.cpp -o ./obj/local/armeabi/objs/g729_jni/g729_jni.o 


In file included from jni/g729_jni.cpp:34:
jni/g729/g729a.h:70: error: 'UWord8' has not been declared
jni/g729/g729a.h:126: error: 'UWord8' has not been declared
jni/g729_jni.cpp: In function 'jint Java_org_sipdroid_codecs_G729_open(JNIEnv*, _jobject*)':
jni/g729_jni.cpp:72: error: 'UWord8' was not declared in this scope
jni/g729_jni.cpp: In function 'jint Java_org_sipdroid_codecs_G729_encode(JNIEnv*, _jobject*, _jshortArray*, jint, _jbyteArray*, jint)':
jni/g729_jni.cpp:111: error: 'UWord8' was not declared in this scope
jni/g729_jni.cpp:111: error: expected ';' before 'serial'
jni/g729_jni.cpp:125: error: 'serial' was not declared in this scope
jni/g729_jni.cpp: In function 'jint Java_org_sipdroid_codecs_G729_decode(JNIEnv*, _jobject*, _jbyteArray*, _jshortArray*, jint)':
jni/g729_jni.cpp:156: error: cannot convert 'unsigned char*' to 'int*' for argument '2' to 'void g729a_dec_process(void*, int*, Word16*, Flag)'
make: *** [obj/local/armeabi/objs/g729_jni/g729_jni.o] Error 1

I googled to try and find the reason behind this error. As C++ is case sensitive, if we make a mistake in upper and lower case, then this kind of error occurs. But I didn't make this kind of mistakes.

If you have any idea or suggestion then please guide me through that.

Thanks

UPDATE:

[root@localhost sipdroid-read-only]# /usr/src/android-ndk-r8/ndk-build V=1 APP_ABI=armeabi APP_PROJECT_PATH=. obj/local/armeabi/objs/g729_jni/g729_jni.o
make: `obj/local/armeabi/objs/g729_jni/g729_jni.o' is up to date.

Solution

  • Make sure your typedef.h is similar to http://siphon.googlecode.com/svn/trunk/g729a/Headers/typedef.h

    Here are the steps I made to reproduce your problem:

    svn checkout http://sipdroid.googlecode.com/svn/trunk/ sipdroid
    cd sipdroid
    sed "s/^SILK/include $(CLEAR_VARS)\\nSILK/" -i jni/Android.mk
    

    (note that Android.mk needed a fix after line 89).

    svn checkout http://siphon.googlecode.com/svn/trunk/ ../siphon
    cp -d ../siphon/g729a/Headers/ jni/g729
    wget http://pastie.org/pastes/4737332/download -O jni/g729/g729a.h
    wget "http://sipdroid.googlecode.com/issues/attachment?aid=7963991223373796529&name=g729_jni.cpp&token=KHEZCoq6ZYSuV_VhsV8fC3uwsSs%3A1348058591979" -O jni/g729_jni.cpp
    sed -e "s/g722_jni/g729_jni/" -i jni/Android.mk
    ndk-build.cmd V=1 APP_ABI=armeabi APP_PROJECT_PATH=. obj/local/armeabi/objs/g729_jni/g729_jni.o
    

    ... and your file compiles with a small warning. What have you done differently?