Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cabal install `gcc' failed in phase `C Compiler'

I want to use parsec for a personal project. But when I invoke cabal install parsec, I get an error:

clang: error: unknown argument: '-no-pie'
gcc' failed in phase `C Compiler'. (Exit code: 1)

I am on OS X El Capitan, 10.11.6. If I have understood correctly he error message above, gcc seems to be the cause. When I check the version of gcc, I get

gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Besides, I have read this `gcc.exe' failed in phase `C Compiler'. (Exit code: 1) and after stack setup--reinstall, stack install parsec worked very well. But cabal always not. Can you help me?

like image 970
Etienne Bernard Avatar asked May 17 '18 08:05

Etienne Bernard


1 Answers

I had the same problem in the same time :-)

Most answers I’ve found on stackoverflow is about to update Xcode.

But! I’ve seen that suggestions since 2013, and in that case, I can’t update Xcode, because I have old Macbook and OS X 10.11 on it, i have tried: brew install gcc Next step I wondering how to setup Gnu C Compler over Xcode and found right now how. Open in terminal with your fav. editor:

mate /Library/Frameworks/GHC.framework/Versions/8.4.2-x86_64/usr/lib/ghc-8.4.2/settings

And change this:

, ("C compiler command","gcc")
, ("C compiler flags"," -fno-stack-protector")
, ("C compiler link flags"," ")
, ("C compiler supports -no-pie","YES")
, ("Haskell CPP command","gcc")

with /usr/local/bin/gcc-8 instead gcc & "NO" instead "YES»

Hope it helps <3

like image 83
Searge Avatar answered Nov 16 '22 01:11

Searge