1. Not found libffmpeg.so
Application.mk
APP_ABI := armeabi-v7a
APP_STL := stlport_static
#APP_STL := gnustl_static
APP_CPPFLAGS := -fno-rtti
APP_CPPFLAGS += -fexceptions
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg
LOCAL_SRC_FILES := ../libffmpeg.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
NDK_LIBDIR=/opt/android/ndk-r9d/platforms/android-19/arch-arm
FFMPEG_HOME=/usr/local/android/ffmpeg
LOCAL_MODULE := tt.x
LOCAL_SRC_FILES := ../tt.cpp
LOCAL_C_INCLUDES := $(ANDROID_NDK)/sources/cxx-stl/stlport/stlport
LOCAL_C_INCLUDES += ../
LOCAL_C_INCLUDES += include
LOCAL_C_INCLUDES += $(FFMPEG_HOME)/include
LOCAL_CPPFLAGS := -Wall -Wno-multichar -D__STDC_CONSTANT_MACROS
LOCAL_LDLIBS := -L$(NDK_LIBDIR)/usr/lib -landroid -llog -L$(FFMPEG_HOME)/lib -lffmpeg
#LOCAL_LDLIBS += $(ANDROID_NDK)/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a
#LOCAL_SHARED_LIBRARIES := ffmpeg
include $(BUILD_EXECUTABLE)
#include $(BUILD_SHARED_LIBRARY)
当采用上述红色部分而不是蓝色部分来连接libffmpeg.so时候,执行tt.x时将报下述错误。
(即使你将libffmpeg.so拷贝到/system/lib/, 和 当前执行目录的obj/local/armeabi-v7a 目录下)
soinfo_link_image(linker.cpp:1635): could not load library
"./obj/local/armeabi-v7a/libffmpeg.so" needed by "./tt.x";
caused by load_library(linker.cpp:745): library "./obj/local
/armeabi-v7a/libffmpeg.so" not foundCANNOT LINK EXECUTABLE
2. 执行程序core dump
当你写一个基于omx解码执行程序, 并连接binder, android, stagefrighthw, stagefright etc
库, 同时连接libffmpeg.so库, 在执行程序中调用相关ffmpeg库函数, 但是执行程序发生
core dump。
刚开始我以为是ffmpeg库编译,连接有问题, 但后来发现, 如果去掉omx, binder相关部分,
执行程序能正确调用ffmpeg相关函数。
这个原因还没有找到, 写在这儿, 便于提醒自己。
3. libavcodec/log2_tab.o: multiple definition of 'ff_log2_tab' 解决办法
新增文件 libavutil/log2_tab.h, 其内容如下
#ifndef AV_LOG2TAB_H
#define AV_LOG2TAB_H
#include <stdint.h>
extern const uint8_t ff_log2_tab[256];
#endif
将所有报上述类似错误的, 做如下修改
如:修改 libavcodec/log2_tab.c, 将log2_tab.c改为log2_tab.h
// #include "libavutil/log2_tab.c"
#include "libavutil/log2_tab.h"
4. error: libavformat/golomb_tab.o: multiple definition of 'ff_interleaved_dirac_golomb_vlc_code' 解决方法
修改 libavformat/golomb_tab.c, 如下:
// #include "libavcodec/golomb.c"
#include "libavcodec/golomb.h"
5. libavutil/eval.o:eval.c:function av_strtod: error: undefined reference to 'avpriv_strtod'
将compat/strtod.c 中的代码复制粘贴到libavutil/eval.c
pasted from compat/strtod.c begin
#include "libavutil/avstring.h"
#include "libavutil/mathematics.h"
static char *check_nan_suffix(char *s)
{
char *start = s;
if (*s++ != '(')
return start;
while ((*s >= 'a' && *s <= 'z') || (*s >= 'A' && *s <= 'Z') ||
(*s >= '0' && *s <= '9') || *s == '_')
s++;
return *s == ')' ? s + 1 : start;
}
#undef strtod
double strtod(const char *, char **);
double avpriv_strtod(const char *nptr, char **endptr)
{
char *end;
double res;
/* Skip leading spaces */
while (av_isspace(*nptr))
nptr++;
if (!av_strncasecmp(nptr, "infinity", 8)) {
end = nptr + 8;
res = INFINITY;
} else if (!av_strncasecmp(nptr, "inf", 3)) {
end = nptr + 3;
res = INFINITY;
} else if (!av_strncasecmp(nptr, "+infinity", 9)) {
end = nptr + 9;
res = INFINITY;
} else if (!av_strncasecmp(nptr, "+inf", 4)) {
end = nptr + 4;
res = INFINITY;
} else if (!av_strncasecmp(nptr, "-infinity", 9)) {
end = nptr + 9;
res = -INFINITY;
} else if (!av_strncasecmp(nptr, "-inf", 4)) {
end = nptr + 4;
res = -INFINITY;
} else if (!av_strncasecmp(nptr, "nan", 3)) {
end = check_nan_suffix(nptr + 3);
res = NAN;
} else if (!av_strncasecmp(nptr, "+nan", 4) ||
!av_strncasecmp(nptr, "-nan", 4)) {
end = check_nan_suffix(nptr + 4);
res = NAN;
} else if (!av_strncasecmp(nptr, "0x", 2) ||
!av_strncasecmp(nptr, "-0x", 3) ||
!av_strncasecmp(nptr, "+0x", 3)) {
/* FIXME this doesn't handle exponents, non-integers (float/double)
* and numbers too large for long long */
res = strtoll(nptr, &end, 16);
} else {
res = strtod(nptr, &end);
}
if (endptr)
*endptr = end;
return res;
}
pasted from compat/strtod.c end
typedef struct Parser {
const AVClass *class;
int stack_index;
char *s;
const double *const_values;
const char * const *const_names; // NULL terminated
double (* const *funcs1)(void *, double a); // NULL terminated
const char * const *func1_names; // NULL terminated
double (* const *funcs2)(void *, double a, double b); // NULL terminated
const char * const *func2_names; // NULL terminated
void *opaque;
int log_offset;
void *log_ctx;
#define VARS 10
double *var;
} Parser;
然后注释掉compat/strtod.c中的代码