这可能很简单。
我有一个使用NDK的Android项目。我想在本机代码中包含opus源代码。我已经尝试使用CMake的ExternalProject_Add属性,但我的本机代码仍然无法从Opus库导入标头而无法构建。
以下是我的ExternalProject_Add定义:
ExternalProject_Add(project_opus
URL https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
BUILD_COMMAND make
INSTALL_COMMAND make install
)
ExternalProject_Get_Property(project_opus install_dir)
include_directories(${install_dir}/include)
add_library(opus SHARED IMPORTED)
add_dependencies(opus project_opus)
target_link_libraries( # Specifies the target library.
native-lib
# Links the target library to the log library
# included in the NDK.
${log-lib} opus oboe OpenSLES)
答案 0 :(得分:2)
所以,这是opus的 CMakeLists.txt :
LOCAL_PATH := .
include $(CLEAR_VARS)
#include the .mk files
include $(LOCAL_PATH)/celt_sources.mk
include $(LOCAL_PATH)/silk_sources.mk
include $(LOCAL_PATH)/opus_sources.mk
MY_MODULE_DIR := opus
LOCAL_MODULE := $(MY_MODULE_DIR)
#fixed point sources
SILK_SOURCES += $(SILK_SOURCES_FIXED)
#ARM build
CELT_SOURCES += $(CELT_SOURCES_ARM)
SILK_SOURCES += $(SILK_SOURCES_ARM)
LOCAL_SRC_FILES := \
$(CELT_SOURCES) \
$(SILK_SOURCES) \
$(OPUS_SOURCES) \
$(OPUS_SOURCES_FLOAT)
LOCAL_LDLIBS := -lm -llog
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/silk \
$(LOCAL_PATH)/silk/fixed \
$(LOCAL_PATH)/silk/float \
$(LOCAL_PATH)/celt
# don't disable the float api
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=1 -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -O3 -fno-math-errno
LOCAL_CPPFLAGS := -DBSD=1
LOCAL_CPPFLAGS += -ffast-math -O3 -funroll-loops
include $(BUILD_SHARED_LIBRARY)
在此文件旁边,您必须将我从android-ffmpeg-builder借来的 opus.mk 文件放在GitHub上:
PAGES-
pages.pageId(INT),
pages.pageTitle(VARCHAR),
ARTICLES-
articles.acrticleId(INT),
articles.articleTitle(VARCHAR),
articles.pageId(INT),
VIDEOS-
videos.videoId(INT),
videos.videoTitle(VARCHAR),
videos.videoLoc(VARCHAR),
videos.articlesId(INT),
IMAGES-
images.imageId(INT),
images.imageTitle(VARCHAR),
images.imageLoc(VARCHAR),
images.articlesId(INT),
TEXT-
text.textId(INT),
text.text(medium),
text.articlesId(INT),
从表面上看,这只支持ARM构建。