Android NDK编译libPng为静态库

首先下载libPng。

在libPng文件夹目录我们新建一个文件夹Android

然后在新建一个Android工程

android create project -n libpng -a MainActivity -t 3 -p ./Android -k com.test.xgame.libpng

新建jni文件夹

新建Android.mk 和 Application.mk

下面是内容

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := libPng
LOCAL_CFLAGS := -Wall
LOCAL_SRC_FILES := \
	../../png.c \
	../../pngerror.c \
	../../pngget.c \
	../../pngmem.c \
	../../pngpread.c \
	../../pngread.c \
	../../pngrio.c \
	../../pngrtran.c \
	../../pngrutil.c \
	../../pngset.c \
	../../pngtrans.c \
	../../pngwio.c \
	../../pngwrite.c \
	../../pngwtran.c \
	../../pngwutil.c
	
LOCAL_CPPFLAGS +=-fexceptions

LOCAL_LDLIBS := -lz

include $(BUILD_STATIC_LIBRARY)


Application.mk

APP_ABI := armeabi armeabi-v7a
APP_PLATFORM:=android-8
APP_STL:=gnustl_static
APP_MODULES :=libPng

NDK编译静态库和动态库不同,静态库mk文件

Android.mk

LOCAL_MODULE := libPng

这里是自己手动加lib

include $(BUILD_STATIC_LIBRARY)

静态库标志


Application.mk

APP_MODULES :=libPng

多出上面这行

你可能感兴趣的:(Android)