0

I want to use opemmp with clang compile in Windows and here is my compile command:

clang++ 1.cpp -o 1.exe -fopenmp=libomp -I=\"C:\\Program Files\\LLVM\\lib\\clang\\9.0.0\\include\" -L=\"C:\\Program Files\\LLVM\\bin\" -Wall -g -O2 -static-libgcc --target=x86_64-w64-mingw -std=c++17

and there is an error:

C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\ld.exe: cannot find -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)

but I have the "libomp.lib" file and write the link path in command argument. How to solve it?

Thanks!

  • The "libomp.lib" you have is maybe the one of MSVC. I think Clang++ should rather use its own "libomp.a" ([as MinGW mainly rely on .a library](https://stackoverflow.com/questions/7241047/linking-lib-files-with-mingw)). Some version of Clang are not provided with an OpenMP runtime and you need to download it manually ([here](https://www.openmprtl.org/download)) – Jérôme Richard Mar 07 '20 at 19:34
  • Thanks a lot! I found I have "libgomp.a" file in MinGW folder, so I change the argument `-fopenmp=libomp` to `-lgomp` and it works well! – Qjbtiger Mar 08 '20 at 03:05

0 Answers0