如何使用Android NDK重建某个android-imagemagick存储库?

时间:2018-07-17 08:06:29

标签: android android-ndk imagemagick

我想在当前项目中使用ImageMagick移植到Android中,并牢记this repository。我现在的问题是,我想重建该存储库以包含distortImage功能-我需要它来进行脸部变形,而jmagick存储库(此存储库部分基于此存储库)的维护者说我可以在自己中添加该功能。因此,我找到了所需的修改文件here,并替换了magick_MagickImage.c目录中的jni文件,并将其他.java文件添加到了src/magick目录中。

我的问题是,当我执行rebuild脚本(第一行更改为export NDK=<my downloaded NDK path>)时,得到以下日志:

Android NDK: Found platform level in F:/android-imagemagick/project.properties. Setting APP_PLATFORM to android-8.
Android NDK: android-8 is unsupported. Using minimum supported version android-14.
Android NDK: WARNING: APP_PLATFORM android-14 is higher than android:minSdkVersion 8 in F:/android-imagemagick/AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android-14. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.
Android NDK: WARNING:F:/Android-ImageMagick/ndk-modules/ImageMagick-6.7.3-0/magick/Android.mk:MagickCore: LOCAL_LDLIBS is always ignored for static libraries   
Android NDK: WARNING:F:/Android-ImageMagick/ndk-modules/ImageMagick-6.7.3-0/magick/Android.mk:MagickCore: non-system libraries in linker flags: -lfreetype -lpng
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK:     current module
Android NDK: WARNING:F:/android-imagemagick/jni/Android.mk:android-magick: non-system libraries in linker flags: -lfreetype -lpng
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK:     current module
F:/android-ndk-r17b/build//../build/core/build-binary.mk:688: Android NDK: Module android-magick depends on undefined modules: png freetype z
F:/android-ndk-r17b/build//../build/core/build-binary.mk:701: *** Android NDK: Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies)    .  Stop.

与此同时,我当前在Android.mk目录中的jni如下:

# C                  opyrieht (C) 2009 The Android Open Source Project
#                    
# L                  icensed under the Apache License, Version 2.0 (the "License");
# y                  ou may not use this file except in compliance with the License.
# Y                  ou 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 $(LOCAL_PATH)/../lib/freetype/jni/Android.mk
#include $(LOCAL_PATH)/../lib/libpng/jni/Android.mk
#include $(LOCAL_PATH)/../lib/zlib/jni/Android.mk
#include $(LOCAL_PATH)/../ndk-modules/jpeg/Android.mk
#include $(LOCAL_PATH)/../ndk-modules/tiff/Android.mk

include $(CLEAR_VARS)

Magick_Home := F:/ImageMagick-7.0.8-6
LOCAL_MODULE    := android-magick
LOCAL_SRC_FILES := jmagick.c
LOCAL_SRC_FILES += magick_DrawInfo.c
LOCAL_SRC_FILES += magick_ImageInfo.c
LOCAL_SRC_FILES += magick_Magick.c
LOCAL_SRC_FILES += magick_MagickImage.c
LOCAL_SRC_FILES += magick_MagickInfo.c
LOCAL_SRC_FILES += magick_MontageInfo.c
LOCAL_SRC_FILES += magick_PixelPacket.c
LOCAL_SRC_FILES += magick_QuantizeInfo.c \
                   magick_MagickBitmap.c

#LOCAL_MODULE := freetype
#LOCAL_SRC_FILES := $(LOCAL_PATH)/../lib/libfreetype.a

#LOCAL_MODULE := png
#LOCAL_SRC_FILES := $(LOCAL_PATH)/../lib/libpng.a

#LOCAL_MODULE := z
#LOCAL_SRC_FILES := $(LOCAL_PATH)/../lib/libz.a

LOCAL_C_INCLUDES += $(Magick_Home)/include/ImageMagick
LOCAL_CFLAGS += -L$(Magick_Home)/lib
LOCAL_STATIC_LIBRARIES := MagickCore jpeg coders tiff-static filters
LOCAL_SHARED_LIBRARIES += MagickCore jpeg coders tiff-static filters

#LOCAL_SHARED_LIBRARIES := MagickCore png15 bz2 gomp pthread
LOCAL_LDLIBS += -L$(LOCAL_PATH)/../lib -lz -lfreetype -lpng -llog


include $(BUILD_SHARED_LIBRARY)

$(call import-module,ImageMagick-6.7.3-0)
$(call import-module,jpeg)

我应该以某种方式链接位于libfreetype.a文件的libpng.a目录中的静态libz.alibAndroid.mk文件吗?因为如果我取消注释多余的三行LOCAL_MODULELOCAL_SRC_FILES,则日志中的错误消息将变为:

Android NDK: WARNING:F:/Android-ImageMagick/ndk-modules/ImageMagick-6.7.3-0/filters/Android.mk:filters: LOCAL_LDLIBS is always ignored for static libraries
Android NDK: WARNING:F:/Android-ImageMagick/ndk-modules/tiff/Android.mk:tiff-static: LOCAL_LDLIBS is always ignored for static libraries
F:/android-ndk-r17b/build//../build/core/build-binary.mk:688: Android NDK: Module tiffinfo depends on undefined modules: tiff
F:/android-ndk-r17b/build//../build/core/build-binary.mk:701: *** Android NDK: Aborting (set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies)    .  Stop.

在此之前,我几乎从未使用过NDK,所以我对应该做什么感到困惑。那么,我应该在这里做什么?另外,使用Windows的cmdcygwin执行ndk-build有什么区别吗?

0 个答案:

没有答案