未定义的me脚解码功能 [英] undefined lame decode function
问题描述
我正在尝试向我的Android应用程序添加MP3读写功能.我正在使用lame4android应用程序作为起点.对文件进行编码对我来说有效,但是我在使用解码功能时遇到了问题-我获得了对解码功能的未定义引用.
I'm trying to add MP3 read and write capabilities to my Android app. I'm using the lame4android app as a starting point. Encoding a file works for me, but I'm having a problem with the decode functions -- I'm getting undefined references to the decode functions.
这是我包装器的摘录.
#include "libmp3lame/lame.h"
#include "jni.h"
lame_t lame;
jint Java_com_intonia_dandy_WavStream_initEncoder(JNIEnv *env,
jobject jobj,
jint in_num_channels,
jint in_samplerate)
{
lame = lame_init();
...
return lame_init_params(lame);
}
hip_t hip;
jint Java_com_intonia_dandy_WavStream_initDecoder(JNIEnv *env, jobject jobj)
{
hip = hip_decode_init();
return hip != 0;
}
这是来自lame.h的声明:
And here are the declarations from lame.h:
lame_global_flags * CDECL lame_init(void);
typedef hip_global_flags *hip_t;
hip_t CDECL hip_decode_init(void);
我收到一条错误消息:
C:/ACode/dandy/src/main/jni/./wrapper.c:62: undefined reference to `hip_decode_init`
我也得到了对hip_decode
和hip_decode_exit
的未定义引用.但是lame_init
,lame_init_params
,lame_encode_buffer
和lame_encode_flush
不会产生任何错误.我使用命令行运行ndk-build时遇到这些错误,而让Android Studio管理编译时也会遇到相同的错误.
I'm also getting undefined references to hip_decode
and and hip_decode_exit
. But lame_init
, lame_init_params
, lame_encode_buffer
, and lame_encode_flush
do not generate any errors. I get these errors using the command line to run ndk-build, and I get the same errors when I let Android Studio manage the compilation.
lame_*
功能与hip_decode_*
功能有何不同?我应该使用不推荐使用的lame_decode_*
吗?
How are the lame_*
functions different from the hip_decode_*
functions? Should I be using the deprecated lame_decode_*
?
我正在看ndk-build命令的输出. .c文件在编译时会在控制台上列出. hip_decode_init
是在jni/libmp3lame/mpglib_interface.c
中定义的,但是即使mpglib_interface
在jni/Android.mk
中列出了,也不会对其进行编译.为什么不呢?
I'm looking at the output of the ndk-build command. The .c files are listed on the console as they are compiled. hip_decode_init
is defined in jni/libmp3lame/mpglib_interface.c
, but mpglib_interface
is not getting compiled, even though it's listed in jni/Android.mk
. Why not???
推荐答案
事实证明,分布式LAME库未启用解码.为了使其正常工作,我必须执行以下操作:
It turns out that the LAME library as distributed does not have decoding enabled. To get it working, I had to do the following:
-
将
#define HAVE_MPGLIB 1
添加到mpglib_interface.c
从LAME发行版的mpglib目录中复制所有.c和.h文件.
Copy all .c and .h files from the mpglib directory of the LAME distribution.
编辑Android.mk以包括mpglib中的.c文件.
Edit Android.mk to include the .c files from mpglib.
不是修改mpglib_interface.c来定义HAVE_MPGLIB
,
最好设置编译标志.
instead of modifying mpglib_interface.c to define HAVE_MPGLIB
,
it's better to set compilation flags.
在使用Android Studio 2+时,build.gradle应该包含
Working with Android Studio 2+, build.gradle should contain
android {
defaultConfig {
ndk {
moduleName "libmp3lame"
cFlags "-DSTDC_HEADERS -DHAVE_MPGLIB"
}
}
}
或者在Android.mk中:
Or in Android.mk:
LOCAL_CFLAGS = -DSTDC_HEADERS -DHAVE_MPGLIB
这篇关于未定义的me脚解码功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!