NDK:未声明

3
我正在使用Android本地库NDK编译C++代码,但是在尝试在g729_jni.cpp中包含g729a.h文件时出现以下错误: 错误:
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

我谷歌搜索了这个错误的原因。由于C++是大小写敏感的,如果我们在大小写方面犯了错误,就会出现这种错误。但我并没有犯这种错误。
如果您有任何想法或建议,请指导我。
谢谢
更新:
[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.

1
请使用参数V=1运行ndk-build以回显命令,并发布导致报告错误的编译步骤。 - Alex Cohn
翻译:抱歉,我复制/粘贴时出了错。请删除“.cmd”,因为我已在我的答案中进行了修复(“ndk-build.cmd”适用于Windows)。如果您看到“g729_jni.o已经是最新的。”,则表示您之前的构建成功了。您可以随时运行“ndk-build clean”并重试。 - Alex Cohn
没问题,但我仍然收到相同的消息“g729_jni.o已经是最新的”,请问在Android.mk的第89行之后需要进行哪些修复? - Juned
我正在使用Sipdroid 2.7 beta的源代码。 - Juned
1
抱歉,我误解了你上次的评论。当然,我已经按照你的建议和步骤去做了,这对我很有帮助。 - Juned
显示剩余4条评论
1个回答

2

请确保您的typedef.h与http://siphon.googlecode.com/svn/trunk/g729a/Headers/typedef.h相似。

以下是我重现您问题所采取的步骤:

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

(请注意,在第89行之后需要修复Android.mk文件。)
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

你的文件编译时出现了一个小警告,你做了什么不同寻常的事情吗?


是的,其实我在使用Siphon的源代码,只是添加了一个名为g729a.h的新文件。 - Juned
你需要在 extern "C" 中包含 jni/g729/g729a.h,但是该文件本身是 C++ 感知的。尝试将此 #include 移出 g729_jni.cpp 的 extern "C" 括号后再编译。 - Alex Cohn
我尝试将#include "g729/g729a.h"放在extern "C"之外,但是出现了更多的错误。点击这里查看 - Juned
很奇怪...对我来说一切都像魔法一样运作...请查看更新后的答案,以获取逐步说明。我们在某些地方做事情的方式不同... - Alex Cohn
非常感谢您的支持,我会尝试使用这个并且如果遇到任何问题会及时告知您。是的,我已经从ITU官方网站下载了g729源代码,但是在那个g729a.h文件中没有找到,所以我使用了Siphon的g729a.h文件。 - Juned
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接