ncnn icon indicating copy to clipboard operation
ncnn copied to clipboard

使用riscv工具链编译时的一个问题

Open panhu opened this issue 1 year ago • 3 comments
trafficstars

detail | 详细描述 | 詳細な説明

我在使用riscv工具链编译ncnn的时候出现一个错误: [ 99%] Built target ncnn [ 99%] Building CXX object benchmark/CMakeFiles/benchncnn.dir/benchncnn.cpp.obj [100%] Linking CXX executable benchncnn /home/Xuantie-900-gcc-elf-newlib-x86_64-V2.0.5/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: cannot find -lpthread collect2: error: ld returned 1 exit status make[2]: *** [benchmark/CMakeFiles/benchncnn.dir/build.make:98:benchmark/benchncnn] 错误 1 make[1]: *** [CMakeFiles/Makefile2:169:benchmark/CMakeFiles/benchncnn.dir/all] 错误 2 make: *** [Makefile:136:all] 错误 2

求教,这要咋解决?用的centos

panhu avatar Dec 05 '23 09:12 panhu

更新最新的工具链

nihui avatar Dec 05 '23 09:12 nihui

我将src的cmakelists修改成: if(NCNN_TARGET_ARCH STREQUAL "riscv") target_compile_options(ncnn PRIVATE -march=rv32imafdcpzpsfoperand_xtheade -mabi=ilp32d -mcmodel=medlow -g2 -Os -DSHL_BUILD_REF -DSHL_BUILD_GREF -DSHL_BUILD_E907 -DSHL_BUILD_RTOS) endif() 是可以得到elf32了,但是会出现错误: [100%] Linking CXX executable benchncnn /home/Xuantie-900-gcc-elf-newlib-x86_64-V2.0.5/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: ../src/libncnn.a(allocator.cpp.obj): ABI is incompatible with that of the selected emulation: target emulation elf32-littleriscv' does not match elf64-littleriscv' /home/Xuantie-900-gcc-elf-newlib-x86_64-V2.0.5/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file ../src/libncnn.a(allocator.cpp.obj) /home/Xuantie-900-gcc-elf-newlib-x86_64-V2.0.5/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: ../src/libncnn.a(benchmark.cpp.obj): ABI is incompatible with that of the selected emulation: target emulation elf32-littleriscv' does not match elf64-littleriscv' /home/Xuantie-900-gcc-elf-newlib-x86_64-V2.0.5/bin/../lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file ../src/libncnn.a(benchmark.cpp.obj) 不知道咋解决

panhu avatar Dec 06 '23 07:12 panhu

如果注释掉 add_subdirectory(benchmark)没报错,但是得到的库文件会特别大,30+M

panhu avatar Dec 06 '23 13:12 panhu