C ++可以与OpenMP一起编译并在MacOS上增强吗? [英] Is C++ compilable with OpenMP and boost on MacOS?
问题描述
我现在已经尝试了很多事情,并得出了一些结论.也许,我监督了一些事情,但似乎我无法完成自己想要的事情.
I have tried many things now and have come to some conclusions. Maybe, I oversee something but it seems that I cannot accomplish what I desire.
问题是:是否有可能通过OpenMP和boost在MacOS High Sierra上编译C ++?
The question is: Is there any possibility to compile C++ on MacOS High Sierra with OpenMP and boost?
一些发现(如果我错了,请纠正我):
Some findings (correct me if I am wrong):
- Clang BUT支持OpenMP,而不是MacOS随附的标准MacOS-clang编译器,这也是XCode9唯一支持的编译器
- g ++支持OpenMP
- 如果我通过自制软件安装Boost,则它将使用clang编译器(无法轻松更改),因此将使用libc ++.
- g ++默认使用libstdc ++,这不容易更改
结果,似乎我不能同时拥有这两种...仅当我使用gcc时才支持OpenMP.但是gcc使用libstdc ++而不是libc ++,因此,如果我尝试使用libc ++链接到通过自制程序安装的boost,则会出现链接器错误.
As a consequence, it seems that I cannot have both... OpenMP is only supported if I use gcc. But gcc uses libstdc++ instead of libc++, so that I get linker errors if I try to link against boost installed via homebrew with libc++.
是否有机会同时运行OpenMP和Boost?
Is there any chance to get both OpenMP and and boost running?
PS:请不要链接到已有1年以上历史的线程,XCode8是另一个故事(较早的XCode版本支持不同的编译器),而clang-omp则是另一个故事(不再受支持).
PS: Please don't link to some >1 year old threads, XCode8 is another story (earlier XCode versions support different compilers) and clang-omp would be another story (it is no longer supported).
推荐答案
自从您在传递brew install clang-omp
时提到过,它已被合并到brew install llvm
中.如果愿意,那确实是一个非常有用的选择,因为如果需要的话,您会得到llvm 5和C ++ 17.使用标准选项(即-fopenmp
),它与OpenMP完全兼容.
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
).
您也可以尝试使用我的冲泡公式来使用内置的叮当声,但是您仍然需要像Alexey Bataev的回答中那样设置自定义选项.使用brew安装:
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
这仅添加了openMP动态库和标头,仅此而已.然后使用:
This only adds the openMP dynamic library and header, nothing else. Then build with:
clang++ -Xpreprocessor -fopenmp -lomp <other arguments...>
请参见自述文件.如果您使用的是cmake,则帮助文件此处可能会有所帮助.
See the readme. If you are using cmake, the helper file here might help.
这篇关于C ++可以与OpenMP一起编译并在MacOS上增强吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!