【问题标题】:Flutter C Interop with omp.h on iOSFlutter C 与 iOS 上的 omp.h 互操作
【发布时间】:2020-08-01 09:54:20
【问题描述】:

我正在尝试在 iOS 的 Flutter 中进行 C 互操作。 该代码使用 omp.h 并且在 Xcode 中编译它时显示 omp.h 未找到。 我试过的:

  • 安装 OpenMP 库。

  • 在 Xcode 中将编译器更改为 GCC,但没有找到任何方法。

  • 在代码文件夹中手动包含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)

有人遇到过这样的问题吗?

【问题讨论】:

    标签: c objective-c swift xcode flutter


    【解决方案1】:

    需要更多信息才能知道究竟发生了什么。但我猜是:

    1. 通过file 命令检查您的库,它是否包含 x86_64 架构。

    2. 使用__attribute__((used))来装饰你的C函数,比如:

    __attribute__((used)) void increment(){
    //...
    }
    

    在你的情况下。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-19
      • 1970-01-01
      • 1970-01-01
      • 2021-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-10
      相关资源
      最近更新 更多