Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android NDK 使用(多個)靜態庫生成動態庫

android NDK 使用(多個)靜態庫生成動態庫

編輯:關於Android編程

android NDK 使用(多個)靜態庫生成動態庫。

1、編寫Android.mk文件:如下兩種方式都可以,用於NDK編譯工具生成的兩個.a文件來生成最終的libtwolib-second.so動態庫。

LOCAL_PATH:=$(callmy-dir)

include$(CLEAR_VARS)

LOCAL_MODULE:=libtwolib-second

LOCAL_SRC_FILES:=second.c

LOCAL_LDFLAGS:=first.athird.a

LOCAL_LDLIBS:=-L$(SYSROOT)/usr/lib-llog

include$(BUILD_SHARED_LIBRARY)

方式二:

LOCAL_PATH:=$(callmy-dir)

include$(CLEAR_VARS)

LOCAL_MODULE:=libtwolib-first

LOCAL_SRC_FILES:=first.a

include$(PREBUILT_STATIC_LIBRARY)

include$(CLEAR_VARS)

LOCAL_MODULE:=libtwolib-third

LOCAL_SRC_FILES:=third.a

include$(PREBUILT_STATIC_LIBRARY)

include$(CLEAR_VARS)

LOCAL_MODULE:=libtwolib-second

LOCAL_SRC_FILES:=second.c

LOCAL_STATIC_LIBRARIES:=libtwolib-firstlibtwolib-third

LOCAL_LDLIBS:=-L$(SYSROOT)/usr/lib-llog

include$(BUILD_SHARED_LIBRARY)

2、生成動態庫

# Android.mk for FFmpeg

# Lei Xiaohua à×???è

# [email protected]

# http://blog.csdn.net/leixiaohua1020

#

LOCAL_PATH := $(call my-dir)

# FFmpeg library

include $(CLEAR_VARS)

LOCAL_MODULE := avcodec

LOCAL_SRC_FILES := libavcodec-57.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := avdevice

LOCAL_SRC_FILES := libavdevice-57.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := avfilter

LOCAL_SRC_FILES := libavfilter-6.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := avformat

LOCAL_SRC_FILES := libavformat-57.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := avresample

LOCAL_SRC_FILES := libavresample-3.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := avutil

LOCAL_SRC_FILES := libavutil-55.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := swresample

LOCAL_SRC_FILES := libswresample-2.so

include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := swscale

LOCAL_SRC_FILES := libswscale-4.so

include $(PREBUILT_SHARED_LIBRARY)

# Program

include $(CLEAR_VARS)

LOCAL_MODULE := sffstreamer

LOCAL_SRC_FILES :=simplest_ffmpeg_streamer.c

LOCAL_C_INCLUDES += $(LOCAL_PATH)/include

LOCAL_LDLIBS := -llog -lz

LOCAL_SHARED_LIBRARIES := avcodec avdevice avfilter avformat avutil avresample swresample swscale

include $(BUILD_SHARED_LIBRARY)

附:

可以直接編寫Android.mk文件來生成兩個.a文件,如下:

LOCAL_PATH:=$(callmy-dir)

include$(CLEAR_VARS)

LOCAL_MODULE:=libtwolib-first

LOCAL_SRC_FILES:=first.c

include$(BUILD_STATIC_LIBRARY)

include$(CLEAR_VARS)

LOCAL_MODULE:=libtwolib-third

LOCAL_SRC_FILES:=third.c

include$(BUILD_STATIC_LIBRARY)

include$(CLEAR_VARS)

LOCAL_MODULE:=libtwolib-second

LOCAL_SRC_FILES:=second.c

LOCAL_STATIC_LIBRARIES:=libtwolib-firstlibtwolib-third

LOCAL_LDLIBS:=-L$(SYSROOT)/usr/lib-llog

include$(BUILD_SHARED_LIBRARY)

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved