Is C++ compilable with OpenMP and boost on MacOS?

佐手、 提交于 2019-12-06 10:42:27

Standard Apple's clang supports OpenMP. They just disabled the driver option. But you can use the frontend option instead this way: clang -Xclang -fopenmp <you_program> -L <path to libomp.a> -lomp

Also, you need to set DYLD_LIBRARY_PATH environmental variable: export DYLD_LIBRARY_PATH=<path to libomp.dylib>

Since you mentioned in passing brew install clang-omp, it's been merged into brew install llvm. That's really a very useful choice if you are willing to do it, since you get llvm 5 and C++17 if you need it. It's fully OpenMP compatible using the standard options (ie, -fopenmp).

You can also try my brew formula to use the built-in clang, but you'd still need to set up custom options as in Alexey Bataev's answer. Install with brew:

brew install cliutils/apple/libomp

This only adds the openMP dynamic library and header, nothing else. Then build with:

clang++ -Xpreprocessor -fopenmp -lomp <other arguments...>

See the readme. If you are using cmake, the helper file here might help.

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