1

I'm trying to compile an algorithm package received by someone else. Basically all I need to do is run a bash script and everything will be compiled automatically. Now upon executing the script, I get a lot of errors, such as:

clang: error: unsupported option '-fopenmp'

My understanding is that the Apple LLVM does not support OpenMPI, so what I did is install the newest gcc version by installing LLVM (version 4.0) through Homebrew. I tried to add this to my bash profile by adding the following (found on the web – my apologies, this isn't my home terrain):

# export PATH=/usr/local/opt/llvm/bin:$PATH
# export CPLUS_INCLUDE_PATH=$(llvm-config --includedir):$CPLUS_INCLUDE_PATH 
# export LD_LIBRARY_PATH=$(llvm-config --libdir):$LD_LIBRARY_PATH 

But this unfortunately didn't do the trick. I get the same errors, and I found out my computer still uses clang:

$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Does anybody know what to do? I can't use another installer by specifying the version, since it's a long bash script, and I wouldn't know what to change where.

  • Seeing later comments and also looking again at your environment variables I think we need to see the script to answer this - also do you know that the application works on OSX? (LD_LIBRARY_PATH is suspicious) – Mark Sep 19 '18 at 11:44
1

You change the script - or better use a build system makefile, cmake, waf etc to have the full path to the C++ compiler and not rely on the $PATH.

Alternatively see of the package has been ported to Homebrew and use that or if only to fink or MAcPorts see how they changed the script.

Lastly make the build as a Homebrew formula making use of Homebrew's own build tools

  • I'm not familiar with g++, so my question really relates on how to change the compiler that is used by default. – falidoro Sep 18 '18 at 20:13
  • That is a very broad question - it depends on the build method - most scripts do not depend on the PATH Many us the $CC environment variable to point to the C++ compiler – Mark Sep 19 '18 at 11:41
-1

Didn't think carefully about it, but did you try to "brew link --force" LLVM?

Check the current compilers, e.g.

iMac:~ sir$ which gcc-6
/usr/local/bin/gcc-6
iMac:~ sir$ which gcc
/usr/bin/gcc

then, do e.g.

ln -s /usr/local/bin/gcc-6 /usr/bin/gcc

you might have to sudo.

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – Allan May 1 '17 at 22:53
  • What do you mean? It is not a clarification request. It is an answer : do "brew link --force gcc" – user2707001 May 1 '17 at 22:56
  • Please don't do that. You edited your post from being a question to a declarative statement. If you are wondering, you can view the edit history by clicking on the "edited (some elapsed time) ago" link at the bottom of your post. That said, the "answer" is still short on details like why should the OP do this? – Allan May 1 '17 at 23:13
  • 1
    I highly encourage you to take the Tour so that you will have an idea how this site works; it's apparent you you're not aware. – Allan May 2 '17 at 0:19
  • 1
    This does not solve the problem unfortunately. g++ --version still gives me the Apple LLVM – falidoro May 3 '17 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .