1

当我添加LOCAL_ARM_NEON := trueandroid.mk 时应用程序中止,即使没有任何霓虹灯指令。一些像“-mfpu=neon”这样的词也会导致中止。

我的手机是motorola android2.2
我在Android NDK 中的配置不正确吗?还是我的手机臂不支持霓虹灯指示?我需要在手机上运行霓虹灯指令。

帮帮我!!!谢谢!!!

ps:应用程序.mk:

APP_STL := gnustl_static
APP_ABI := armeabi-v7a
APP_CPPFLAGS += -fexceptions
APP_MODULES := AudioEngine

安卓.mk:

CC = $(BASE_PATH)/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-gcc 
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_ARM_NEON := true
LOCAL_MODULE    := AudioEngine
LOCAL_SRC_FILES := AudioEngine.cpp Effecter.cpp SoundTouch.cpp TDStretch.cpp RateTransposer.cpp AAFilter.cpp BPMDetect.cpp \
FIFOSampleBuffer.cpp FIRFilter.cpp mmx_optimized.cpp PeakFinder.cpp sse_optimized.cpp cpu_detect_x86.cpp fft.s\
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
LOCAL_LDLIBS := -llog

include $(BUILD_SHARED_LIBRARY)
4

2 回答 2

1

我使用我编写的第二个小型 .so 库来检查 CPU 是否完全支持 NEON。检查后,我决定在 java 中我必须加载哪个版本的库,一个完全支持 NEON,一个完全不支持 NEON:这是从 NDK 文档中获取的代码:

JNIEXPORT JNICALL int Java_xypackagename_base_detectCPU_isNeon( JNIEnv* _env, jobject thiz )
{
    uint64_t features;

    if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM)
    {
        __android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor is NOT an ARM processor" );
        return 0;
    }

    __android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor is an ARM processor" );

    features = android_getCpuFeatures();

    __android_log_print( ANDROID_LOG_INFO, "detectCPU", "Processor features: %u", (unsigned int)features );

    if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7) == 0)
    {
        __android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor is NOT an ARM v7" );
        return 0;
    }

    __android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor is an ARM v7" );

    if ((features & ANDROID_CPU_ARM_FEATURE_NEON) == 0)
    {
        __android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor has NO NEON support" );
        return 0;
    }

    __android_log_write( ANDROID_LOG_INFO, "detectCPU", "Processor has NEON support" );

    return 1;
}
于 2013-01-29T15:22:41.687 回答
0

在官方的 Hello-Neon-Example 中使用了以下方法:

安卓.mk:

# inside a module:

LOCAL_SRC_FILES := helloneon.c

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_CFLAGS := -DHAVE_NEON=1
    LOCAL_SRC_FILES += helloneon-intrinsics.c.neon
endif

#...

一些 C/C++ 源文件:

/* HAVE_NEON is defined in Android.mk */
#ifdef HAVE_NEON
    callNeonFunc();
#else
    callStandardFunc();
#endif
于 2013-07-28T02:29:11.563 回答