ncnn arm linux,编译arm-linux时为何编译的却是x86

@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

if(NOT TARGET OpenMP::OpenMP_CXX)

find_package(Threads REQUIRED)

add_library(OpenMP::OpenMP_CXX IMPORTED INTERFACE)

set_property(TARGET OpenMP::OpenMP_CXX

PROPERTY INTERFACE_COMPILE_OPTIONS ${OpenMP_CXX_FLAGS})

# Only works if the same flag is passed to the linker; use CMake 3.9+ otherwise (Intel, AppleClang)

set_property(TARGET OpenMP::OpenMP_CXX

PROPERTY INTERFACE_LINK_LIBRARIES ${OpenMP_CXX_FLAGS} Threads::Threads)

endif()

endif()

if(WIN32)

add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)

add_definitions(-DNOMINMAX)

else()

add_definitions(-Wall -Wextra -Wno-unused-function)

add_definitions(-fPIC)

if(CMAKE_BUILD_TYPE MATCHES "(Release|RELEASE|release)")

add_definitions(-Ofast)

add_definitions(-ffast-math)

endif()

if(PI3)

add_definitions(-march=native)

add_definitions(-mfpu=neon)

add_definitions(-mfloat-abi=hard)

add_definitions(-D__ARM_NEON)

add_definitions(-D__ANDROID__)

endif()

# add_definitions(-march=native)

# add_definitions(-flto)

add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden)

endif()

if(ANDROID)

#if(TRUE) #ljy modify

# disable shared library on android

set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")

elseif(IOS)

# disable shared library on xcode ios

set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值