Mac running OpenMP, “clang: error: unsupported option '-fopenmp'”

帅比萌擦擦* 提交于 2019-12-13 04:18:01

问题


I am new to OpenMP, and my professor gives us a project to do. There are only three files in the folder: a C++ source code a0.cpp, a header a0.h, and a Makefile. When I want to run the code in my terminal, it says:

clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
make: *** [a0] Error 1

I am using a Macbook, and I do not know how to fix this. Can you help me? Thanks.


回答1:


After installing libomp with homebrew using:

brew install libomp

I was able to compile an OpenMP program with this:

clang -Xpreprocessor -fopenmp -I/usr/local/include -L/usr/local/lib -lomp  main.c -o main

If you are using C++, you'd likely want:

clang++ -Xpreprocessor -fopenmp -I/usr/local/include -L/usr/local/lib -lomp  main.cpp -o main


来源:https://stackoverflow.com/questions/58275167/mac-running-openmp-clang-error-unsupported-option-fopenmp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!