projectNe10 / Ne10

An open optimized software library project for the ARM® Architecture
Other
1.46k stars 408 forks source link

ndk r21 不能正常编译ne10,如何成功编译并能在android studio中使用 #259

Open YYLSomeOne opened 4 years ago

YYLSomeOne commented 4 years ago

编译报错内容如下: In file included from /home/android/Android/Ne10/common/NE10_mask_table.h:32:0, from /home/android/Android/Ne10/common/NE10_mask_table.c:32: /home/android/Android/Ne10/inc/NE10_types.h:39:20: fatal error: assert.h: 没有那个文件或目录 compilation terminated. modules/CMakeFiles/NE10.dir/build.make:62: recipe for target 'modules/CMakeFiles/NE10.dir//common/NE10_mask_table.c.o' failed make[2]: *** [modules/CMakeFiles/NE10.dir//common/NE10_mask_table.c.o] Error 1 CMakeFiles/Makefile2:85: recipe for target 'modules/CMakeFiles/NE10.dir/all' failed make[1]: [modules/CMakeFiles/NE10.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: [all] Error 2

运行命令如下: export ANDROID_NDK=/home/android/Android/SDK/ndk/21.3.6528147 export NE10_ANDROID_TARGET_ARCH=aarch64 export ANDROID_API_LEVEL=24 cmake -DCMAKE_TOOLCHAIN_FILE=../android/android_config.cmake ..

修改../android/android_config.cmake如下:

NDK_SYSROOT_PATH is used in compiler's '--sysroot' flags

#set(NDK_SYSROOT_PATH "$ENV{ANDROID_NDK}/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_NDK_PLATFORMS_ARCH_SUFFIX}/")
#set(NDK_ISYSROOT_PATH "$ENV{ANDROID_NDK}/sysroot -I$ENV{ANDROID_NDK}/sysroot/usr/include/${ANDROID_NDK_TOOLCHAIN_CROSS_PREFIX}")
set(/home/android/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot)
if(APPLE)
    #TODO: Check whether this path is correct for aarch64 under mac.
    #set(ANDROID_TOOLCHAIN_PATH "$ENV{ANDROID_NDK}/toolchains/${ANDROID_NDK_TOOLCHAIN_CROSS_PREFIX}-${ARM_ANDROID_TOOLCHAIN_VERSION}/prebuilt/darwin-x86_64/bin")        
    set(/home/android/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/)
else()
    #set(ANDROID_TOOLCHAIN_PATH "$ENV{ANDROID_NDK}/toolchains/${ANDROID_NDK_TOOLCHAIN_CROSS_PREFIX}-${ARM_ANDROID_TOOLCHAIN_VERSION}/prebuilt/linux-x86_64/bin")
    set(/home/android/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/)
endif()

#change toolchain name according to your configuration
#set(CMAKE_C_COMPILER ${ANDROID_TOOLCHAIN_PATH}/${ANDROID_NDK_TOOLCHAIN_CROSS_PREFIX}-gcc)
#set(CMAKE_CXX_COMPILER ${ANDROID_TOOLCHAIN_PATH}/${ANDROID_NDK_TOOLCHAIN_CROSS_PREFIX}-g++)
set(/home/android/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++)
set(/home/android/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/clang)

#find_program(CMAKE_AR NAMES "${ANDROID_TOOLCHAIN_PATH}/${ANDROID_NDK_TOOLCHAIN_CROSS_PREFIX}-ar")
#find_program(CMAKE_RANLIB NAMES "${ANDROID_TOOLCHAIN_PATH}/${ANDROID_NDK_TOOLCHAIN_CROSS_PREFIX}-ranlib")
find_program(CMAKE_AR NAMES /home/android/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar)
find_program(CMAKE_RANLIB NAMES /home/android/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ranlib)