openmp in MAC OS 10.12.6 - macos

I tried to install openmp in OS 10.12.6 following the instructions given here
https://www.quora.com/How-do-I-Install-OpenMP-on-Mac-10-11-6
but the simple command
brew install clang-omp
did not work and I got the error
Error: No available formula with the name "clang-omp".
Then following the instructions contained here
brew install clang-omp not working
I tried to reinstall llvm by doing
brew reinstall llvm
and the installation was successful but I see no trace of omp. If I try to compile with g++ or gcc a simple program including <omp.h> and compiling with the -fopenmp flag I get
clang: error: unsupported option '-fopenmp'
even if I checked that in other cases it has worked (Enable OpenMP support in clang in Mac OS X (sierra)).
I've tried to look for openmp in mac port as well but I haven't managed to find it. Thank you for your help.

You need a recent version of llvm and libomp which you can get with
brew install llvm
brew install libomp

Related

Switching GCC version to use on macbook M1

I received this error when I tried to compile by gcc 11.x and run some code on my Macbook Pro M1
E ImportError: dlopen(/Users/giangpham/VSCode/rpxdock/rpxdock/bvh/bvh.cpython-37m-darwin.so, 0x0006): tried: ‘/Users/giangpham/VSCode/rpxdock/rpxdock/bvh/bvh.cpython-37m-darwin.so’ (mach-o file, but is an incompatible architecture (have ‘arm64’, need ‘x86_64’))
I tried to install another homebrew for x86_64 architecture and install the old gcc ver 9 (which is the version recorded to have worked with the code before) following this article
I have done axbrew info gcc and it would still give out information of the 11.x gcc (axbrew info gcc#9 works and gives me info of the package. But I tried switch`` as the article suggested and it saids unknown command```). How do I switch gcc to use the older version I just installed?
Thank you!

gcc via homebrew has no --without-multilib option

I want to install xgboost in Python 3.5. This requires gcc to support -fopenmp option. Default gcc does not support it. So I am using
brew install gcc --without-multilib
But I get Warning: gcc: this formula has no '--without-multilib' option so it will be ignored! Any ideas?
The option no longer exists, since 8/2017. Many older 3rd-party xgboost instructions are outdated. Just do brew install gcc without options and be amazed that everything still works.

Compiling haskell with llvm

I'm starting to learn Haskell and I found out that ghc can compile using LLVM with the -fllvm flag. Whenever I use the flag, I get the error message:
<no location info>: error:
Warning: Couldn't figure out LLVM version!
Make sure you have installed LLVM 3.7
ghc: could not execute: opt
However, I have opt in my /usr/local/Cellar/llvm/3.9.0/ folder. I'm on a Mac OS X and I've installed the full LLVM with brew install llvm but error persists. Is this a genuine version problem where I have to unistall LLVM and reinstall its 3.7 version? Or is ghc having trouble finding opt and there is some kind of search path I can modify to fix the problem? Thanks for the help and have a great day.
The GHC documentation says that it's compatible with llvm-2.8+, but as you've discovered, it actually requires llvm-3.7.
The simplest way to get it is:
brew install llvm#3.7
This installs llvm binaries in your path with a -3.7 suffix, like clang-3.7. GHC will need the unadorned names, which are in a subdirectory:
export PATH=/usr/local/opt/llvm#3.7/lib/llvm-3.7/bin:$PATH

two versions of gcc on Mac Sierra and build fails

I keep failing to build a project with error
configure: error: C preprocessor "/lib/cpp" fails sanity check
I checked and found two versions of gcc on my Mac Sierra
/Applications/Xcode.app/Contents/Developer/usr/bin/gcc and
/Library/Developer/CommandLineTools/usr/bin/gcc
both gives version x86_64-apple-darwin16.0.0
then on default path /usr/local/bin/gcc, it is version
x86_64-apple-darwin14.0.0
I suspect the default version is the wrong one which causes the build to fail, but brew upgrade gcc does not fix it. I tried brew unlink gcc, did not remove
/usr/local/bin/gcc, and it is still the default gcc
How to remove the x86_64-apple-darwin14.0.0 version, and force the system to use the x86_64-apple-darwin16.0.0 version?

Why can't I compile with gfortran after upgrading to OSX Yosemite? gfortran error: libgfortran.spec: No such file or directory

Since upgrading to Yosemite I cannot compile with gfortran. Initially I was getting "segmentation fault 11", then I:
Updated to gcc v.5.0 from http://hpc.sourceforge.net/
Re-installed Xcode command line utilities v.6.1.1
After doing the above, I am able to compile very simple fortran programs but the more complex code that I run gives me the following error:
gfortran: error: libgfortran.spec: No such file or directory
But in fact, the libgfortran.spec file is located in /usr/local/lib
ls /usr/local/lib | grep gfortran
libgfortran.3.dylib
libgfortran.a
libgfortran.dylib
libgfortran.la
libgfortran.spec
All of the gcc binaries are located in /usr/local/bin
which gfortran
/usr/local/bin/gfortran
And my path seems to be OK
echo $PATH
/usr/local/lib:/usr/local/bin:/usr/local:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/lib:/usr/texbin:/Users/MattCooper/bin:/Applications/MRT/bin
I also tried re-installing gcc with homebrew:
brew install gcc
Error: gcc-4.9.2 already installed
To install this version, first 'brew unlink gcc'
However, I get v. 5.0 when I ask 'gcc --version':
gcc --version
gcc (GCC) 5.0.0 20141005 (experimental)
When I try to unlink or upgrade gcc with homebrew I get a permission denied error:
brew unlink gcc
Unlinking /usr/local/Cellar/gcc/4.9.2... Error: Permission denied - /usr/local/bin/c++-4.9
similarly
brew upgrade gcc
Permission denied - /usr/local/bin/c++-4.9
Finally
which gcc
/usr/local/bin/gcc
Please help. Many thanks ahead of time. Please let me know what I've forgotten to include.
I ended up solving the problem via homebrew. I can't pinpoint the exact source of the problem but it was related to the fact that I installed gcc v4.9 from http://hpc.sourceforge.net/, then somewhere along the way I re-installed and/or updated gcc with homebrew. Then, after upgrading to Yosemite, I installed gcc v5 from http://hpc.sourceforge.net/. Somewhere within that process, the binaries within /usr/local/bin and usr/local/lib were not linked properly.
The main clue was the Permission Denied error when trying to run 'brew upgrade gcc'. I found a solution here: Brew doctor says: "Warning: /usr/local/include isn't writable."
To fix, I used:
brew doctor
which returned a bunch of directories that were not writeable, for example usr/local/lib, thus brew was unable to ugrade gcc to the v5.0 and link everything.
I went through and issued:
sudo chown -R $USER /usr/local
and did this for all of the other non-writeable directories returned by 'brew doctor'. Then, I was able to use brew to ugrade gcc:
brew upgrade gcc
During the ugrade, homebrew returned an error that stated it could not finish the upgrade because there was already an existing gfortran file located in:
/usr/local/bin/gfortran
To fix, homebrew suggested I run:
brew -link gcc
at which point everything worked. Interesting (to me, because I don't fully understand all of this) when I ask brew to clean things up, I get:
brew cleanup
Warning: Skipping (old) /usr/local/Cellar/gcc/4.9.2 due to it being linked
There's some similar information located here: How to link to a new gcc version with brew?
Similar to that user, when I look in my cellar, I find two versions of gcc, but I'm not sure if I need both
ls /usr/local/Cellar/gcc
4.9.2 4.9.2_1
I had a similar issue with similar solution. It could not find this file:
gfortran: error: libgfortran.spec: No such file or directory
So my problem was that I had installed gcc through hpc.sourceforge.net and through homebrew. I had to uninstall the homebrew version
brew uninstall gcc
Then I had to reinstall the gcc from hpc.sourceforge.net
sudo tar -xvf gcc-4.9-bin.tar.gz -C /
This worked for me when I wanted to revert to gcc 4.9 from hpc.sourceforge.net, using Yosemite.

Resources