I've prebuilt library (libxxx.so) with "-mfloat-abi=hard" parameter. Now i'd like to compile my native code with this lib and build shared lib (.so) with ndk.
Application.mk:
APP_ABI := armeabi-v7a
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := xxx
LOCAL_SRC_FILES := libxxx.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS) LOCAL_MODULE := xxx_wrapper
LOCAL_SRC_FILES := xxx_wrapper.cpp xxx_wrapper.h
LOCAL_SHARED_LIBRARIES := xxx
LOCAL_C_INCLUDES := /softdev/host/include/
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
LOCAL_ARM_NEON := true
LOCAL_CXXFLAGS += -mfpu=vfp -mfloat-abi=hard
LOCAL_CFLAGS += -mfpu=vfp -mfloat-abi=hard
include $(BUILD_SHARED_LIBRARY)
on ndk-build
i'm getting an error:
/softdev/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: /Users/asmirnov/Documents/dev/src/project/obj/local/armeabi-v7a/objs-debug/xxx_wrapper/xxx_wrapper.o uses VFP register arguments, output does not /softdev/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: /Users/asmirnov/Documents/dev/src/project/obj/local/armeabi-v7a/libxxx.so uses VFP register arguments, output does not collect2: ld returned 1 exit status
How can i fix it? Both .o files are hard-float according to output and i can't figure out what "output" means? I've added '-mfpu=vfp -mfloat-abi=hard' to my module description.
UPDATE: i've executed ndk-build V=1 and found no "-mfpu=vfp -mfloat-abi=hard" arguments in command-line, so i i've tried to do it manually (but still no result):
mba-anton:build asmirnov$ /softdev/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++
-Wl,-soname,libxxx_wrapper.so -shared --sysroot=/softdev/android-ndk-r8e/platforms/android-8/arch-arm /Users/asmirnov/Documents/dev/src/xxx_jni/obj/local/armeabi-v7a/objs-debug/xxx_wrapper/xxx_wrapper.o /Users/asmirnov/Documents/dev/src/xxx_jni/obj/local/armeabi-v7a/libstdc++.a -lgcc /Users/asmirnov/Documents/dev/src/xxx_jni/obj/local/armeabi-v7a/libxxx.so -no-canonical-prefixes -march=armv7-a -mfpu=vfp -mfloat-abi=hard -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -L/softdev/android-ndk-r8e/platforms/android-8/arch-arm/usr/lib -L/usr/lib -llog -lstdc++ -lc -lm -o /Users/asmirnov/Documents/dev/src/xxx_jni/obj/local/armeabi-v7a/libxxx_wrapper.so /softdev/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: /Users/asmirnov/Documents/dev/src/xxx_jni/obj/local/armeabi-v7a/objs-debug/xxx_wrapper/xxx_wrapper.o uses VFP register arguments, output does not /softdev/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: /Users/asmirnov/Documents/dev/src/xxx_jni/obj/local/armeabi-v7a/libxxx.so uses VFP register arguments, output does not collect2: ld returned 1 exit status
You may want this: -march=armv7-a -mfloat-abi=softfp -mfpu=vfp
In a word, "-mfloat-abi=hard" or "-mfloat-abi=softfp" argument does not refers to use hardware or software FPU.
Please see Getting hardware floating point with android NDK for more details, fadden has given a great and clear answer, so I won't bother to repeat it here.
Solution:
APP_ABI := armeabi-v7a-hard
instead of
APP_ABI := armeabi-v7a
Also you can add these flags in Android.mk:
LOCAL_CXXFLAGS := -O2 -mfpu=vfpv3-d16 -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -march=armv7-a -mfloat-abi=hard
LOCAL_CFLAGS := -O2 -mfpu=vfpv3-d16 -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -march=armv7-a -mfloat-abi=hard
LOCAL_LDFLAGS := -lm_hard
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With