为 Android 编译 Opus 编解码器所需的 Makefile [英] Makefile needed for compiling the Opus Codec for Android

查看:26
本文介绍了为 Android 编译 Opus 编解码器所需的 Makefile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译 opus 音频编解码器 (http://www.opus-codec.org/downloads/) 用于 Android 应用程序.我正在使用 Android NDK(版本 6)来编译我的库.到目前为止,我必须为我的应用程序编译的本机 C 库非常简单,我已经能够将我的 Android.mk 文件基于 jni,主要基于教程或其他示例.但是,Opus 的编译看起来要复杂一些.tar.gz 存档包含一个用于为 Windows 编译库的解决方案文件,它还包含一些用于标准 Unix 实现的 Makefile,但将这些文件转换为 Android.mk makefile 以供 Android NDK 使用有点挑战.

I am trying to compile the opus audio codec (http://www.opus-codec.org/downloads/) for use in an Android application. I am using Android NDK (release 6) to compile my libraries. Up to now, the native C libraries that I had to compile for my application has been pretty straightforward and I have been able to base my Android.mk files in jni mostly on tutorials or other examples. However, the compilation of Opus looks to be somewhat more complex. The tar.gz archive contains a solution file for compiling the libraries for Windows and it also contains some Makefiles for a standard Unix implementation, but translating these into an Android.mk makefile for use by the Android NDK is a bit of a challenge.

我已经搜索过,但一直无法找到用于编译 libopus 的 Android makefile 的在线版本.有人可以将我链接到这样的makefile吗?或者,我可能会遗漏一些更简单的东西?是否可以使用 Automake 或某种转换器从 tar.gz 中已包含的 unix makefile 为我生成 Android.mk 文件?

I have searched, but have been unable to find an online version for the Android makefile to compile libopus. Can someone perhaps link me to such a makefile? Alternatively, I might be missing something simpler? Is it perhaps possible to use Automake or some kind of converter to maybe generate the Android.mk file for me from the unix makefile that is already included in the tar.gz?

推荐答案

以下是最终对我有用的 Android.mk makefile.我希望这也可以在将来对其他人有所帮助.请注意,在 Opus 存档中包含的 unix makefile 中,是否使用固定或浮动丝绸源的决定被定义为ifdef",而这里我使用的是固定".(使用float"很简单 - 只需将路径silk/fixed"更新为指向silk/float"并更新 CFLAGS.

The following is the Android.mk makefile that eventually worked for me. I hope this can help someone else too in future. Do take note that in the unix makefile included in the Opus Archive, the decision of whether to use the fixed or float silk sources is defined as an "ifdef" whereas here I am using "fixed". (To use "float" would be simple - simply update the paths "silk/fixed" to point to "silk/float" and update the CFLAGS.

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

MY_MODULE_DIR       := opus

LOCAL_MODULE        := $(MY_MODULE_DIR)
LOCAL_SRC_FILES     := 
    $(subst $(ROOT_DIR)/$(MY_MODULE_DIR)/,,$(wildcard $(ROOT_DIR)/$(MY_MODULE_DIR)/src/*.c*)) 
    $(subst $(ROOT_DIR)/$(MY_MODULE_DIR)/,,$(wildcard $(ROOT_DIR)/$(MY_MODULE_DIR)/celt/*.c*)) 
    $(subst $(ROOT_DIR)/$(MY_MODULE_DIR)/,,$(wildcard $(ROOT_DIR)/$(MY_MODULE_DIR)/silk/*.c*)) 
    $(subst $(ROOT_DIR)/$(MY_MODULE_DIR)/,,$(wildcard $(ROOT_DIR)/$(MY_MODULE_DIR)/silk/fixed/*.c*))
LOCAL_LDLIBS        := -lm -llog
LOCAL_C_INCLUDES    := 
    $(ROOT_DIR)/$(MY_MODULE_DIR)/include 
    $(ROOT_DIR)/$(MY_MODULE_DIR)/silk 
    $(ROOT_DIR)/$(MY_MODULE_DIR)/silk/fixed 
    $(ROOT_DIR)/$(MY_MODULE_DIR)/celt
LOCAL_CFLAGS        := -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS    += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -O3 -fno-math-errno
LOCAL_CPPFLAGS      := -DBSD=1 
LOCAL_CPPFLAGS          += -ffast-math -O3 -funroll-loops

include $(BUILD_STATIC_LIBRARY)

这篇关于为 Android 编译 Opus 编解码器所需的 Makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆