NDK Android - Can't build ARMv5 and V7 at the same time

跟風遠走 提交于 2019-12-07 15:55:31

问题


I'm facing a weird problem. I'm building a shared library for my Android application.

I can't build both armv5 and armv7 at the same time. If I do so, I get a lot of errors on my source files at the second run (when the ndk build the armV7 lib) like:

FinderPatternInfo.o: previous definition here
multiple definition of ...

My Application.mk

APP_ABI             := armeabi armeabi-v7a
APP_PLATFORM        := android-8
APP_STL             := stlport_static
APP_CPPFLAGS        += -fexceptions

It works perfectly if I only set APP_ABI := armeabi or APP_ABI := armeabi-v7a..

Any idea ? Thank you for your help,

EDIT: Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE            := MyModule

MY_LOCAL_INCLUDED_FILES += $(wildcard $(LOCAL_PATH)/*.h)
MY_LOCAL_INCLUDED_FILES += $(wildcard $(LOCAL_PATH)/*.hpp)
MY_LOCAL_INCLUDED_FILES += $(wildcard $(LOCAL_PATH)/bigint/*.h)
... (many includes)

LOCAL_C_INCLUDES        :=  $(subst jni/, , $(MY_LOCAL_INCLUDED_FILES))

MY_LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/*.c)
MY_LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/*.cpp)
MY_LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/bigint/*.c)
.... (many cpp files)

LOCAL_SRC_FILES     :=  $(subst jni/, , $(MY_LOCAL_SRC_FILES))

LOCAL_CFLAGS        := -DNO_ICONV

include $(BUILD_SHARED_LIBRARY)

回答1:


The Android make system parses your Android.mk once for each target, so your MY_LOCAL_SRC_FILES gets a full set of all of your .c and .cpp files twice when there are two targets, but only one of each when there's a single target.

If your first MY_LOCAL_SRC_FILES assignment used := instead of +=, I think it would fix the problem.



来源:https://stackoverflow.com/questions/18187853/ndk-android-cant-build-armv5-and-v7-at-the-same-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!