Skip to content

Fix: Clang: Error: Unsupported option ‘-fopenmp’ 

  • by
  • 2 min read

No matter how easy coding becomes, there will always be random bugs and glitches that developers have to deal with every day. Regardless, while most error messages are descriptive enough to help you navigate the issue on your own if you’re relatively new, you can have some problems. 

In this article, we’re talking about the “Clang: error: unsupported option ‘-fopenmp'” issue, its causes and what you can do to fix the problem.


What causes the “Clang: error: unsupported option ‘-fopenmp'” error?

While there are several reasons that might trigger the error, the most common one is the fact that Clang doesn’t support OpenMP on mac, meaning if you’re running the tool on a Mac device, the error is almost certainly going to come up unless you’re using brew’s llvm. 

Other causes include:

  • Post compilation Linker errors
  • Errors during the build process

Also read: How to fix ‘Clang: Error: No input files’?


How to fix the “Clang: error: unsupported option ‘-fopenmp'” error?

Here are two fixes you can try out.

Use Brew’s llvm

As mentioned before, Apple’s llvm doesn’t support -fopenmp. To counter the problem, we’re going to have to use brew’s llvm. Just open a terminal and run the following commands.

brew install llvm libomp
export CC=/usr/local/opt/llvm/bin/clang

Once you’re done, restart your Mac and you should be good to go. 

Top 7 ides and text editors to code python, java, c++, html and more

Check for Linker errors

After following the aforementioned step, Clang should be working fine. However, in case it doesn’t you should check for any possible Linker errors. To do so, add include and link relevant directories in the CMakeList.txt file as follows.

include_directories(“/usr/local/include” “/usr/local/opt/llvm/include”)
link_directories(“/usr/local/lib” “/usr/local/opt/llvm/lib”)

Then execute the following commands in a terminal window to run CMake with the new compiler.

CMake -DCMAKE_C_COMPILER+”/usr/local/opt/llvm/bin/clang” -DCMAKE_CXX_COMPILER=”/usr/local/opt/llvm/bin/clang++” ..

Also read: Fix: Unknown error: soap-error: encoding: object has no uirequestid property

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: yadullahabidi@pm.me.

>