Closed bigbao9494 closed 5 years ago
@nihui 非常感谢您的回复
我修改src/CmakeLists.txt的第43行,强制进入ARM平台编译
if(TRUE
OR (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|aarch64)"))
这样可以进入ARM平台编译,但是编译时会报错,我看了下代码意思是convolutiondepthwise_3x3_int8.h文件中 未找到int8x8_t类型的定义 内容如下(列出一个错误,其它都同一个错误): /home/ncnn-master_20181128_cross/src/layer/arm/convolutiondepthwise_3x3_int8.h:679:9: 错误:‘int8x8_t’在此作用域中尚未声明 int8x8_t _k0 = vdup_n_s8(kernel[0]); ^ /home/ncnn-master_20181128_cross/src/layer/arm/convolutiondepthwise_3x3_int8.h:680:18: 错误:expected ‘;’ before ‘_k1’ int8x8_t _k1 = vdup_n_s8(kernel[1]);
我在一个arm平台下编译(全志,非android) 发现它编译的是src/layer/x86而不是src/layer/arm 但是我编译Android版本时却是正常的,不知道需要怎样修改才能编译出arm版本呢??? 下面是编译打印: [ 24%] Building CXX object src/CMakeFiles/ncnn.dir/layer/x86/convolution_x86.cpp.obj In file included from /home/ncnn-master_20181128_cross/src/layer/x86/convolution_x86.cpp:19:0:
@nihui 你好 我尝试了#28中的方法,仍然不行,以下是我尝试的方法不知道是否正确: 我使用的芯片是全志的H2 1、 新建一个arm.toolchan.cmake SET(CMAKE_SYSTEM_NANE Android) SET(CMAKE_SYSTEM_PROCESSOR "armv7-a") SET(ANDROID_ARCH_NAME "arm") SET(ANDROID true) SET(CMAKE_C_COMPILER "arm-cortexa9-linux-gnueabihf-gcc") SET(CMAKE_CXX_COMPILER "arm-cortexa9-linux-gnueabihf-g++") 然后:mkdir arm;cd arm;cmake -DCMAKE_TOOLCHAIN_FILE=../arm.toolchain.cmake ..;make -j2 2、 直接修改CMakeLists.txt,全部文件内容如下(注释为ljy的是我添加的内容): if(CMAKE_TOOLCHAIN_FILE) set(LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are compiled to")
get absolute path, but get_filename_component ABSOLUTE only refer with source dir, so find_file here :(
get_filename_component(CMAKE_TOOLCHAIN_FILE_NAME ${CMAKE_TOOLCHAIN_FILE} NAME) find_file(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE_NAME} PATHS ${CMAKE_SOURCE_DIR} NO_DEFAULT_PATH) message(STATUS "CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}") endif()
if(NOT DEFINED CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory") endif() message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
cmake_minimum_required(VERSION 2.8.10)
if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE release CACHE STRING "Choose the type of build" FORCE) endif()
set(COVERAGE OFF CACHE BOOL "Coverage")
project(ncnn)
option(NCNN_OPENMP "openmp support" ON) option(NCNN_STDIO "load model from external file" ON) option(NCNN_STRING "plain and verbose string" ON) option(NCNN_OPENCV "minimal opencv structure emulation" OFF) option(NCNN_BENCHMARK "print benchmark information for every layer" OFF) option(NCNN_PIXEL "convert and resize from/to image pixel" ON) option(NCNN_PIXEL_ROTATE "rotate image pixel orientation" OFF) option(NCNN_CMAKE_VERBOSE "print verbose cmake messages" OFF)
if(NCNN_OPENMP) find_package(OpenMP)
For CMake < 3.9, we need to make the target ourselves
endif()
if(WIN32) add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE) add_definitions(-DNOMINMAX) else()
endif()
if(ANDROID)
if(TRUE) #ljy modify
elseif(IOS)
disable shared library on xcode ios
endif()
##############################################
add_subdirectory(examples)
add_subdirectory(benchmark)
add_subdirectory(src) if(NOT ANDROID AND NOT IOS) add_subdirectory(tools) endif()
add_definitions(-mfpu=neon)#ljy added. add_definitions(-march=native)#ljy added. add_definitions(-mfloat-abi=hard)#ljy added. add_definitions(-D__ARM_NEON)#ljy added.