sap*_*sap 15 c++ openmp c++11 macos-sierra
我试图在我的C++ 11代码中使用一些OpenMP多线程功能,如:
#pragma omp parallel for
Run Code Online (Sandbox Code Playgroud)
当我尝试编译时使用:
clang++ -std=c++11 -stdlib=libc++ -fopenmp main.cpp -o main.o
Run Code Online (Sandbox Code Playgroud)
我得到以下错误:
clang: error: unsupported option '-fopenmp'
Run Code Online (Sandbox Code Playgroud)
我或者尝试使用以下编译:
g++ -fopenmp main.cpp -o main.o
Run Code Online (Sandbox Code Playgroud)
但这给出了完全相同的错误.
非常感谢,如果您可以建议如何在Mac OS 10.12上编译具有OpenMP功能的C++ 11代码.关于这里和其他地方的帖子的其他问题解释了为OpenMP编译C代码,但是,我找不到C++ 11的任何内容.
我尝试安装libiomp时遇到错误,我收到错误:
$ brew install libiomp
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
ansible-cmdb djview4 khard oysttyer shyaml yazpp
asciinema2gif doctl macvim pazpar2 vala you-get
avro-c elixir mailhog python vdirsyncer youtube-dl
bash-git-prompt file-roller meson python3 vim
commandbox glib metaproxy rtv x265
consul-backinator gtkextra offlineimap s-search xonsh
Error: Could not link:
/usr/local/share/doc/homebrew
Please delete these paths and run `brew update`.
Error: Could not link:
/usr/local/share/man/man1/brew.1
Please delete these paths and run `brew update`.
Error: No available formula with the name "libiomp"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.
Run Code Online (Sandbox Code Playgroud)
如果我使用g ++ - 6运行,基于下面的Mark Setchell的帖子,它运行正常,谢谢,我得到以下警告,会感谢任何有关如何避免这些的建议:
$ /usr/local/bin/g++-6 -std=c++11 -fopenmp main.cpp -o main.o
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:4:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:4:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:89:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:89:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:551:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:551:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1432:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1432:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1799:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1799:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1995:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:1995:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2033:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2033:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2425:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2425:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2559:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2559:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2597:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2597:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2672:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2672:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2837:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2837:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2962:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:2962:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3139:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3139:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3442:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3442:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3588:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3588:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3630:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:3630:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:5253:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:5253:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:5452:11: warning: section "__textcoal_nt" is deprecated
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
/var/folders/jr/30r6h4cj4tl48q_cg9bt5f5h0000gn/T//ccq73Zfg.s:5452:11: note: change section name to "__text"
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
^ ~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)
Mar*_*ell 13
更新的答案
由于我在下面的原始答案,情况已经改善,您可以轻松地使用OpenMP与clang++编译器 - hurraaaay!
要做到这一点,首先使用自制软件来安装brew install libomp:
brew install libomp
Run Code Online (Sandbox Code Playgroud)
然后在使用时clang++,使用这些标志:
clang++ -Xpreprocessor -fopenmp main.cpp -o main -lomp
Run Code Online (Sandbox Code Playgroud)
原始答案
如果要在OSX上编译C++ 11 OpenMP代码,最简单的方法是使用gcc可以通过它安装的代码homebrew.
首先,检查可用选项:
brew options gcc
Run Code Online (Sandbox Code Playgroud)
样本输出
--with-all-languages
Enable all compilers and languages, except Ada
--with-java
Build the gcj compiler
--with-jit
Build the jit compiler
--with-nls
Build with native language support (localization)
--without-fortran
Build without the gfortran compiler
--without-multilib
Build without multilib support
--HEAD
Install HEAD version
Run Code Online (Sandbox Code Playgroud)
所以,我怀疑你想要:
brew install gcc --without-multilib --without-fortran
Run Code Online (Sandbox Code Playgroud)
安装完成后,您需要确保使用的是homebrew版本,而不是Apple提供的版本.您需要知道homebrew安装/usr/local/binC++编译器的所有内容g++-6.所以,你要么需要编译:
/usr/local/bin/g++-6 -std=c++11 -fopenmp main.cpp -o main
Run Code Online (Sandbox Code Playgroud)
或者,在您的登录配置文件中设置您的PATH:
export PATH=/usr/local/bin:$PATH
Run Code Online (Sandbox Code Playgroud)
那么你可以这样做:
g++-6 -std=c++11 -fopenmp ...
Run Code Online (Sandbox Code Playgroud)
请注意,如果您选择上面的第二个选项(即export PATH=...选项),您将需要export在当前会话中键入一次命令以激活它,或者注销并重新登录,因为您的配置文件命令仅在登录时执行.
AFAIK,没有必要明确安装libiomp- 不知道你为什么这样做.
| 归档时间: |
|
| 查看次数: |
9454 次 |
| 最近记录: |