【问题标题】:OpenMP with Clang 5.0 and MinGW带有 Clang 5.0 和 MinGW 的 OpenMP
【发布时间】:2018-06-15 02:08:39
【问题描述】:

我无法让 Clang 在 Windows 上与 MinGW 一起工作。 我安装了 MinGW-W64-builds-4.3.3 (GCC 7.2.0) 以及最新的 Clang/LLVM(通过网站上的安装程序)。

我正在编译:

-target x86_64-pc-windows-gnu 

option 和 Clang 查找所有标题。不幸的是,当我使用 OpenMP 时,链接器出现错误。它看起来像这样:

: undefined reference to `__imp___kmpc_fork_call'
\libgomp.a(team.o):(.text+0x19): undefined reference to `pthread_mutex_destroy'
...

当我尝试使用 -fopenmp=libomp 标志时,我收到如下错误:

...: undefined reference to `__imp___kmpc_fork_call'
...: undefined reference to `__imp___kmpc_for_static_init_4'
...: undefined reference to `__imp___kmpc_for_static_fini'
...: undefined reference to `__imp___kmpc_barrier'
...

使用 GCC 编译时,一切正常。 有没有办法让它(openmp)在没有安装 Visual Studio 的情况下工作?如果没有,是否有一些最小化的 Visual Studio 安装程序只提取所需的库/头文件而不是整个 IDE 等?

我当然不知道我在这里做什么。像我一样解释五个答案非常感谢。

【问题讨论】:

标签: windows linker clang mingw openmp


【解决方案1】:

为我解决问题的方法是将 libomp.lib 添加到要编译的文件列表中。这似乎是必要的,无论我是否在编译器选项中有 -static 并且无论它是:

-fopenmp=libomp

-fopenmp=libiomp5

(正如评论者建议的那样)

总结一下,我需要:

clang --target x86_64-pc-windows-gnu -fopenmp=libomp ... C:\FULL\PATH\TO\libomp.lib

使其与 MinGW-W64-builds-4.3.3 和 Clang 5.0.1 一起使用

【讨论】:

    猜你喜欢
    • 2021-07-31
    • 2014-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-04
    • 2019-08-24
    • 2017-02-13
    • 1970-01-01
    相关资源
    最近更新 更多