问题描述
我搜索了很多有关的libpng连接到Android NDK项目的主题,但我已经找到正确的答案我的问题,我希望有人能帮助我。
I've searched a lot of topics about linking libpng to my android ndk project but I've found right answer for my problem and I hope somebody will help me.
这是我的项目的层次结构:
This is hierarchy of my project:
JNI
different_cpp_files
different_hpp_files
Android.mk
libpng
different_cpp_files
different_hpp_files
Android.mk
在Android.mk的libpng文件夹:
Android.mk in libpng folder:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LS_C=$(subst $(1)/,,$(wildcard $(1)/*.c))
LOCAL_MODULE := png
LOCAL_SRC_FILES := \
$(filter-out example.c pngtest.c,$(call LS_C,$(LOCAL_PATH)))
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lz
include $(BUILD_STATIC_LIBRARY)
我想这一切是正确的在这里..
I suppose that everything is right here..
在Android.mk文件夹JNI:
Android.mk in jni folder:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LS_CPP=$(subst $(1)/,,$(wildcard $(1)/*.cpp))
LOCAL_MODULE := pacman
LOCAL_CFLAGS := -Wno-psabi
LOCAL_SRC_FILES := $(call LS_CPP,$(LOCAL_PATH))
LOCAL_LDLIBS := -landroid -llog -lEGL -lGLESv1_CM -lOpenSLES
LOCAL_STATIC_LIBRARIES := android_native_app_glue png
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
$(call import-module,libpng)
最后一行显示,我得到了libpng喜欢native_app_glue LIB(在Android的NDK源目录),现在我想从我的项目的libpng编译。我需要Android.mk改变是什么文件?
The last line shows that I got libpng like native_app_glue lib(in the directory of android-ndk sources) Now I want to compile libpng from my project. What I need to change in Android.mk file?
推荐答案
我已经得到了另一种方式为您提供:
i've got another way for you:
-
从这里下载的所有文件,并将其粘贴到一个新的文件夹中的任何地方你的系统上:结果
进入该文件夹,然后运行:结果 ./ build.sh
go into the folder and run:./build.sh
您将得到一个libpng.a文件中的 [您的文件夹] /obj/local/armeabi/libpng.a
结果
将此文件复制到:结果 [YOUR_ANDROID_NDK_FOLDER] /平台/ [ALL_FOLDERS_IN_HERE] /弓臂/ usr / lib目录/
You will get an libpng.a file in [YOUR_FOLDER]/obj/local/armeabi/libpng.a
Copy this file into:[YOUR_ANDROID_NDK_FOLDER]/platforms/[ALL_FOLDERS_IN_HERE]/arch-arm/usr/lib/
现在你可以用简单的线条您的所有项目使用的libpng:结果 LOCAL_LDLIBS + = -lpng
now you can use libpng in all your projects with the simple line:LOCAL_LDLIBS += -lpng
您只需要包括这在你的CPP的:结果的#include< png.h>
you only have to include this in your cpp's:#include <png.h>
玩得开心!
这篇关于在Android的NDK项目中添加的libpng的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!