我正试图在iOS中实现C级交互。该代码使用omp.h,当在Xcode中对其进行填充时,表示omp.h
未找到。我试过的是:
在Xcode中,
omp.h
。。
当包含omp.h手动的时候,但是现在我得到了这个错误:
Undefined symbols for architecture x86_64:
"_omp_init_nest_lock", referenced from:
_count_3_initialize in count_3_initialize.o
"_omp_destroy_nest_lock", referenced from:
_count_3_terminate in count_3_terminate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我尝试使用dylib,但出现了以下错误:
Unhandled Exception: Invalid argument(s): Failed to lookup symbol (dlsym(RTLD_DEFAULT, increment): symbol not found)
以前有人遇到过这样的问题吗?
发布于 2020-12-09 09:29:20
需要更多的信息才能知道到底发生了什么。但我猜是:
file
命令检查您的库,它是否包含x86_64 arch。__attribute__((used))
来装饰您的C函数,例如:__attribute__((used)) void increment(){
//...
}
在你的案子里。
发布于 2022-11-18 08:21:18
您安装的库可以通过macOS链接(例如,由brew install libomp
安装),您不能使用macOS库来链接iOS或iPhone模拟器。
因此,我们需要自己编写:
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/openmp-14.0.6.src.tar.xz
tar -xf openmp-14.0.6.src.tar.xz
cd openmp-14.0.6.src
mkdir -p build
cmake -B build \
-DCMAKE_TOOLCHAIN_FILE=ios.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./build/install \
-DIOS_PLATFORM=OS -DENABLE_BITCODE=1 -DENABLE_ARC=0 -DENABLE_VISIBILITY=0 -DIOS_ARCH="arm64;arm64e" \
-DPERL_EXECUTABLE=$(which perl) \
-DLIBOMP_ENABLE_SHARED=OFF -DLIBOMP_OMPT_SUPPORT=OFF -DLIBOMP_USE_HWLOC=OFF
cmake --build build -j 3
cmake --build build --target install
以上将为iOS创建一个静态库iOS,如果您也希望为模拟器创建一个库,则需要设置-DIOS_PLATFORM=SIMULATOR
和-DIOS_ARCH="x86_64;arm64"
。
下面是我创建一个OpenMP.xcframework
的实现,它可以同时支持iOS和iPhone模拟器:https://github.com/flyinghead/flycast/pull/805/
https://stackoverflow.com/questions/61296324
复制相似问题