2

I have a program written on Linux in GNU C. The program compiles with GCC. I have an install shell script,

gcc -o program program.c -Wall -pedantic -std=gnu11 -lm -fopenmp

which works greatly.

The problem is with Mac. For some reason, Mac sees gcc and instead uses clang even though GCC is installed and install.sh explicitly says gcc. clang doesn't work with omp.h The problem is that clang can't use omp.h and solutions offered http://releases.llvm.org/3.7.0/tools/clang/docs/ReleaseNotes.html#openmp-support don't work, and omp.h may not work in mac at all Enable OpenMP support in clang in Mac OS X (sierra)

I never use macs, and because of this nonsense I never plan to. However, some people using my program want to use Mac, so I have to deal with this.

I've tried various shell script modifications, but none of them work, mac insists on using clang and won't use gcc

I need to do one of two things which I don't know how to do:

1) force Mac to use gcc (which it refuses to do now)

2) get clang to use omp.h in mac (which from other answers on Stack Overflow, looks impossible)

con
  • 5,767
  • 8
  • 33
  • 62

1 Answers1

1

Your second option (get clang to use omp.h) is not impossible (any more). From my answer here:

Try using Homebrew's llvm:

brew install llvm

You then have all the llvm binaries in /usr/local/opt/llvm/bin. To compile the OpenMP Hello World program, for example, type

/usr/local/opt/llvm/bin/clang -fopenmp -L/usr/local/opt/llvm/lib omp_hello.c -o hello

You might also have to set the CPPFLAGS with -I/usr/local/opt/llvm/include.

Dirk
  • 2,335
  • 24
  • 36