OS X: installed gcc links to clang

假装没事ソ 提交于 2021-02-04 07:27:07

问题


I already have gcc and g++ install:

$ which gcc
/usr/bin/gcc

$ which g++
/usr/bin/g++

$ brew install gcc
Warning: gcc-6.2.0 already installed

I follow Compile OpenMP programs with gcc compiler on OS X Yosemite to reinstall gcc via HomeBrew:

$ brew reinstall gcc --without-multilib

then

$ /usr/bin/g++ openmp.cpp
openmp.cpp:12:10: fatal error: 'omp.h' file not found
#include <omp.h>
         ^
1 error generated.

with -fopenmp

$ /usr/bin/g++ openmp.cpp -fopenmp
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'

What's happening with this redirection? How could I use gcc/g++?


Though involved, it's not about OpenMP.


回答1:


brew installs tools in /usr/local/bin. Use /usr/local/bin/g++6:

$ /usr/local/bin/g++-6 --version
g++-6 (Homebrew gcc 6.2.0) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


来源:https://stackoverflow.com/questions/40034457/os-x-installed-gcc-links-to-clang

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