Open Som5ra opened 1 week ago
And if I use v1.18.1 then would get:
Undefined symbols for architecture arm64:
"_NSLog", referenced from:
onnxruntime::logging::AppleLogSink::SendImpl(std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000l>>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, onnxruntime::logging::Capture const&) in libonnxruntime.a[550](apple_log_sink.mm.o)
"___CFConstantStringClassReference", referenced from:
in libonnxruntime.a[550](apple_log_sink.mm.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You need to add -fobjc-arc
to CMAKE_CXX_FLAGS
You need to add
-fobjc-arc
toCMAKE_CXX_FLAGS
Thanks!! It really helps a lot. But I get a new error when using:
If I use the version that build from scratch:
libc++abi: terminating due to uncaught exception of type Ort::Exception: ONNX format model is not supported in this build.
if i use the pre-built version:
libc++abi: terminating due to uncaught exception of type Ort::Exception
They are all thrown by:
ort_session = Ort::Session(ort_env, model_path.c_str(), session_options);
May I know if this is still a common issue? The code is running well on linux side, with pre-built ort static lib.
Sorry, I have checked my code and it's my own problem, everything works now. Really appreciate your help and I am gonna close the issue.
Hello, I have met another issue when I try using IOS static version.
I am trying using CMake with this ios toolchain (https://github.com/leetal/ios-cmake) to build my library.
set(onnxruntime_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/3rdparty/onnxruntime/onnxruntime.xcframework-1.19.2/onnxruntime.xcframework/Headers")
set(onnxruntime_LIBS "${CMAKE_SOURCE_DIR}/3rdparty/onnxruntime/onnxruntime.xcframework-1.19.2/onnxruntime.xcframework/ios-arm64/libonnxruntime.a")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc")
set(AppleLink "-framework Foundation")
include_directories(${CMAKE_SOURCE_DIR}/include )
add_library( ${PROJECT_NAME} STATIC face_geometry_example_mobile.cpp ${SOURCES} ${CMAKE_SOURCE_DIR}/tools/nms/nms.cpp ${FACE_GEOMETRY_LIBS})
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENMP_INCLUDES} ${onnxruntime_INCLUDE_DIRS})
target_link_libraries( ${PROJECT_NAME} ${AppleLink} ${onnxruntime_LIBS} ${OpenCV_LIBS} ${GLOBAL_LINK_3RD_PARTY_LIBS})
But the CMake seems could not help pack the symbols from static ort libraries with my code together into a single .a file. So I use: libtool -static ... packed all the required .a files.
then I use this static lib to build my project I get:
I think maybe It's the same problem with above issue, but I have no idea how to solve it.
Could you please help me take a look at this? Thanks a lot~
And if I directly use the generated .a lib (only 400kb size), I would get:
All of these symbols are from third-party static libraries (onnxruntime, opencv).
Also, I have seen the similar usage from https://github.com/k2-fsa/sherpa-onnx/blob/master/build-ios-no-tts.sh, but I didn't find any obvious difference between the linking method from sherpa-onnx and mine, is there any keypoints that i missed? Thanks.
Besides, i am using Unity to do this, I am not sure if it's a reason of failing, But I do have succeeded with static opencv lib before, using XCode GUI to do it at that time instead of CMake toolchain.
I am really confused: I saw you use lipo to merge all the static libs here except the libonnxruntime.a (https://github.com/k2-fsa/sherpa-onnx/blob/master/build-ios-no-tts.sh#L135C1-L155C42), it's because there is some exposed functions you need to use in those .a but no direct function you need in libonnxruntime.a right? So if we want to build a static lib, normally we don't need to merge all the .a manually as long as we linked them when building? Please correct me if I am wrong. Thanks and apologize for bringing you so many issues.
Hi Thanks for your amazing work~ I have tried 2 different sources of static libraries,
Both of them have the same error when linking using CMake:
CMake:
Is there anyone who have the same issue? Thanks in advance!