Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译arm-linux时为何编译的却是x86,修改CMakeLists.txt后可以编译ARM,但是有编译错误 #677

Closed
bigbao9494 opened this issue Nov 29, 2018 · 2 comments

Comments

@bigbao9494
Copy link

@nihui 非常感谢您的回复

我修改src/CmakeLists.txt的第43行,强制进入ARM平台编译
#if((IOS AND ${CMAKE_OSX_ARCHITECTURES} MATCHES "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]);

我尝试修改src/CmakeLists.txt,在其中添加neon_arm.h文件的路径,这个路径就是我的工具链的头文件路径
重新cmake;make后仍然提示那个错误
include_directories(/opt/FriendlyARM/toolchain/4.9.3/lib/gcc/arm-cortexa9-linux-gnueabihf/4.9.3/include)

我自己写了一个简单的demo来验证neon是否可以编译
//t1.cpp
#include <stdio.h>
#include
#include <arm_neon.h>
int main(int argc, char argv[])
{
char _kernel[10] = {1,2,3};
const signed char
kernel = (const signed char*)_kernel;
int8x8_t a = vdup_n_s8(kernel[0]);

printf("exit: %d\n",a);
return 0;

}

编译命令:arm-cortexa9-linux-gnueabihf-g++ t1.cpp -mfpu=neon
正常能够通过编译,而且也没有指定include的路径,说明arm-cortexa9-linux-gnueabihf-g++自己会知道工具链的库路径

@bigbao9494
Copy link
Author

@nihui
这个问题我找到根本原因了,是因为修改根目录下CMakeLists.txt文件内容没有对src/CMakeLists.txt产生作用
所以修改src/CmakeLists.txt的第43行,强制进入ARM平台编译,才能真正的生效
#if((IOS AND ${CMAKE_OSX_ARCHITECTURES} MATCHES "arm")
if(TRUE
OR (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm|aarch64)"))
另外编译找不到int8x8_t定义的问题也是一样的,我之前是在根目录下的CMakeLists.txt中添加的
add_definitions(-mfpu=neon)#ljy added.
add_definitions(-D__ARM_NEON)#ljy added.
这些添加内容没有生效,所以编译时找不到neon_arm.h
同样我把这两行放到src/CMakeLists.txt中就可以了
同时下面这行是不需要的,工具链会自己查找到
include_directories(/opt/FriendlyARM/toolchain/4.9.3/lib/gcc/arm-cortexa9-linux-gnueabihf/4.9.3/include)

问题来了,为什么修改根目录中的CMakeLists.txt没有作用呢??还请明示

@nihui
Copy link
Member

nihui commented Dec 18, 2018

https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-raspberry-pi-3
可以参考 raspberry pi3 的编译参数

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants