JNI 呼叫.a 靜態庫檔案
阿新 • • 發佈:2019-02-18
============================================================博文原創,轉載請宣告出處電子咖啡(原id藍巖)============================================================android工程共需要ffmpeg,引入原始碼進行ndk-build編譯,每次需要十五分鐘左右,於是想吧編譯出來的.a檔案直接拿過來使用。
網上東拼西湊總算成功了,這裡吧指令碼分享給大家。
在jni目錄下建立Android.mk和Application.mk檔案,如下,修改相應內容進行編譯,ok。
Android.mk
# Copyright (C) 2009 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := AndroidCamera LOCAL_SRC_FILES := AndroidCamera.cpp \ CameraSelf/CCamDevice_Init.c \ newBuffer/bufferqueue.cpp \ newBuffer/mymalloc.cpp \ CameraSelf/TcpChannel_Connect.c \ newDecoder/DecodeLib.cpp \ CameraSelf/CCamDevice_MAIN.cpp \ LOCAL_STATIC_LIBRARIES := libavformat libavcodec libswscale libavutil libpostproc ffmpeg LOCAL_C_INCLUDES := $(LOCAL_PATH)/newBuffer \ $(LOCAL_PATH)/newDecoder \ $(LOCAL_PATH)/newDecoder/ffmpeg \ $(LOCAL_PATH)/CameraSelf \ LOCAL_ARM_MODE := arm LOCAL_CFLAGS := -D__STDC_CONSTANT_MACROS -I$(LOCAL_PATH)/newDecoder/ffmpeg/ LOCAL_LDLIBS += -llog include $(BUILD_SHARED_LIBRARY) include $(call all-makefiles-under,$(LOCAL_PATH)/newDecoder)
Application.mk
APP_CFLAGS += -fexceptions
#APP_STL := gnustl_static
APP_STL := stlport_static
APP_ABI := armeabi