22

I have a problem with GCC. I want to update it to a new version, from the 4.2.1, to program with parallel programming. However, in this version there is no library . How can I download an updated version?

The error that the terminal give me is:

omp_hello.c:11:10: fatal error: 'omp.h' file not found
#include <omp.h>
         ^
1 error generated.
Mark
  • 2,380
  • 11
  • 29
  • 49
Mattia Baldari
  • 567
  • 1
  • 5
  • 15
  • Your problem is the same as [that one](http://stackoverflow.com/questions/20321988/error-enabling-openmp-ld-library-not-found-for-lgomp-and-clang-errors). – Hristo Iliev Dec 03 '13 at 00:25
  • Thanks for the answer, i tried to do that tutorial ( downloading the files and do the installation ) but for now it doesn't seems work. But i will try again. ( that tutorial isn't for maverick, maybe there is something different ). If i try a solution i will write it here for others. – Mattia Baldari Dec 03 '13 at 07:28
  • The tutorial is perfectly valid for Mavericks. I compiled GCC 4.8.2 on my Mavericks system by following it. – Hristo Iliev Dec 03 '13 at 08:14

4 Answers4

12
  1. download gcc-4.9-bin.tar.gz download or newer from http://hpc.sourceforge.net/: http://prdownloads.sourceforge.net/hpc/gcc-4.9-bin.tar.gz

  2. cd to your downloads folder and un-gzip the archive gunzip gcc-4.9-bin.tar.gz (Google Chrome would do that automatically)

  3. in the same folder run sudo tar -xvf gcc-4.9-bin.tar -C / - this will place new executable to /usr/local/bin

  4. add the following to ~/.bash_profile: export PATH=/usr/local/bin:$PATH

  5. open new terminal and run which gcc. This should point to /usr/local/bin/gcc

erip
  • 16,374
  • 11
  • 66
  • 121
volodymyr
  • 7,256
  • 3
  • 42
  • 45
  • 1
    just to add something some people may need: 1. don't forget "/" in step 3. 2. if u d not know how to add that path in step 4, check this post http://superuser.com/questions/678113/how-to-add-a-line-to-bash-profile – David Oct 09 '15 at 19:25
  • hey, I did all the steps and after typing which gcc, it does show it is in usr/local/bin and 'gcc -v' gives the 4.9 version. However, when I used 'make' to install a program that requires omp.h, it still shows "fatal error: 'omp.h' file not found" and it is still the clang version. Does it have anything to do with the "make" file. When I type 'which make', it is /usr/bin which is where the gcc 4.2 located but gcc 4.9 is at /usr/local/bin/. – kelvinfrog May 25 '16 at 16:24
5

I got this message when I tried to reinstall GCC via Homebrew.

GCC has been built with multilib support. Notably, OpenMP may not work: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60670

If you need OpenMP support you may want to brew reinstall gcc --without-multilib

So, if you have Homebrew installed, you could try (on the terminal):

brew reinstall gcc --without-multilib

This process may take a while !

Community
  • 1
  • 1
Pavithran Iyer
  • 402
  • 5
  • 14
2

According to this thread on apple's forums, try using gcc-4.9-bin.tar .

First install the gcc-4.9 and type "xcode-select --install" on your terminal.

Then, use "/usr/local/bin/gcc " as compiler.

Zack
  • 169
  • 1
  • 4
  • 18
1

I solve it just adding aliases to .bash_profile

# Aliases in order to use brew gcc
alias gcc='gcc-5'
alias cc='gcc-5'
alias g++='g++-5'
alias c++='c++-5'
K. Stopa
  • 597
  • 8
  • 9