alibaba / MNN

MNN is a blazing fast, lightweight deep learning framework, battle-tested by business-critical use cases in Alibaba
http://www.mnn.zone/
8.74k stars 1.67k forks source link

iOS v2.9.5 MNN.framework/Headers/Interpreter.hpp 头文件报错 #3036

Closed YiQiu1984 closed 1 month ago

YiQiu1984 commented 1 month ago

平台(如果交叉编译请再附上交叉编译目标平台):

Platform(Include target platform as well if cross-compiling):

iOS 2.9.5

Github版本:

Github Version:

tag 2.9.5

编译方式:

Compiling Method

xcode直接运行生成MNN.framework


集成MNN.framework时,MNN.framework/Headers/Interpreter.hpp 头文件报错:“MNN/ErrorCode.hpp file not found”。
在MNN.framework里面,是没有MNN这一层目录的。

CMAKE集成:
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  target_include_directories(${PROJECT_NAME} PRIVATE ${LIBMNN_PATH}/iOS/MNN.framework/Headers)
  # link
  target_link_libraries(${PROJECT_NAME} PRIVATE "-framework MNN")
  # framework search dir
  set_target_properties(${PROJECT_NAME} PROPERTIES
            LINK_FLAGS "-Wl,-F  ${LIBMNN_PATH}/iOS")
endif()
YiQiu1984 commented 1 month ago

使用cmake集成xcode编译出来的MNN.framework 集成脚本: if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") target_include_directories(${PROJECT_NAME} PRIVATE ${LIBMNN_PATH}/iOS/MNN.framework/Headers)

link

target_link_libraries(${PROJECT_NAME} PRIVATE "-framework MNN")

framework search dir

set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-Wl,-F ${LIBMNN_PATH}/iOS") endif()

运行时报错: MNN.framework/Headers/Interpreter.hpp 头文件报错:“MNN/ErrorCode.hpp file not found”

jxt1234 commented 1 month ago

framework 中的头文件是适配 xcode 工程引用的,可以自行复制一份头文件出来给 cmake 使用

YiQiu1984 commented 1 month ago

framework 中的头文件是适配 xcode 工程引用的,可以自行复制一份头文件出来给 cmake 使用

是说集成的工程里不使用framework里的头文件,另外copy一份出来是吗?这样运行时会不会报错呢?

YiQiu1984 commented 1 month ago

我想知道xcode工程能不能构建出libMNN.a文件出来呢?我想在C++层使用,能构建出来.a静态库的话,会比较方便

jxt1234 commented 1 month ago
  1. 头文件直接复制就行。MNN的对外头文件保证向下兼容,不会有问题.
  2. 编 .a 的话自己用 cmake 编就好了: mkdir build && cd build cmake ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.toolchain.cmake -DMNN_METAL=ON -DARCHS="arm64" -DENABLE_BITCODE=0 -DMNN_AAPL_FMWK=0 -DMNN_SEP_BUILD=0 -DMNN_ARM82=true -DMNN_BUILD_SHARED_LIBS=false -DMNN_USE_THREAD_POOL=OFF -DMNN_LIB_DIR=. make -j16 make install
jxt1234 commented 1 month ago

具体命令参考脚本 package_scripts/ios/buildiOS.sh ,把 -DMNN_AAPL_FMWK=1 去掉就可以