首页 > 解决方案 > MSYS2:带有 OpenMP 库的 GCC 可以工作,但 OpenMP 无法正常工作

问题描述

在 MSYS2 终端中使用 clang 编译器编译代码时出现以下错误。

在 MSYS2 环境中,它同样适用于带有 OpenMP 的 GCC。

gcc main.c -o main -fopenmp ---> 工作

clang main.c -o main -fopenmp ---> 不工作我遇到以下错误

谁能让我知道这里出了什么问题?

$ clang main.c -o main -fopenmp C:\msys64\mingw64\bin\ld: C:\msys64\tmp\main-f23226.o:main.c:(.text+0x10): undefined reference to omp_get_max_threads' C:\msys64\mingw64\bin\ld: C:\msys64\tmp\main-f23226.o:main.c:(.text+0x28): undefined reference toomp_set_dynamic' C:\msys64\mingw64\bin\ld: C:\msys64\tmp\main-f23226.o:main.c:(.text+0x2d): undefined reference to omp_get_max_threads' C:\msys64\mingw64\bin\ld: C:\msys64\tmp\main-f23226.o:main.c:(.text+0x34): undefined reference toomp_set_num_threads' C:\msys64\mingw64\bin\ld : C:\msys64\tmp\main-f23226.o:main.c:(.text+0x49): 未定义引用__kmpc_fork_call' C:\msys64\mingw64\bin\ld: C:\msys64\tmp\main-f23226.o:main.c:(.text+0xeb): undefined reference to__kmpc_for_static_init_4' C:\msys64\mingw64\bin\ld: C:\msys64\tmp\main- f23226.o:main.c:(.text+0x13d): 未定义对omp_get_thread_num' C:\msys64\mingw64\bin\ld: C:\msys64\tmp\main-f23226.o:main.c:(.text+0x175): undefined reference to__kmpc_for_static_fini' 的引用

标签: clangmsys2

解决方案


推荐阅读