Sunday, November 17, 2013

GCC in OS X Mavericks

GCC in OS X Mavericks

GCC in OS X Mavericks


;; =================================================
;; εμαcs is ⎋[esc]⌘[meta]⌥[alt]⌃[ctrl]⇧[shift].
;; =================================================

This post is written with emacs org-mode.

Operating System Environments

  • Main- : OS X Mavericks (10.9)
  • Sub- : Debian GNU/Linux Wheezy (7.2)
  • Server: Debian GNU/Linux Squeeze || Lenny
  • Mobile: iOS 7.0.4

Installation of GCC(gcc48) via MacPorts

GCC is the GNU Compiler Collection, including front ends for C, C++, Objective-C, Objective-C++, Fortran, and Java. In OS X Mavericks a sort of gcc is preinstalled, but it is based on the Clang. This preinstalled gcc is not fully compatible to GCC(GNU Compiler Collection). Moreover it can compile only C, C++, and Objective-C. I need a Fortran compiler.

Up to OS X Mountain Lion (10.8), GCC(GNU Compiler Collection) has been easily installed via MacPorts. However, in OS X Mavericks (10.9) a GCC(GNU Compiler Collection) port seems to be broken. A problem may be caused by the broken libgcc port that is the mainly dependent port of gcc43, gcc44, gcc45, gcc46, gcc47, gcc48. It cannot be installed via sudo port install libgcc. I don't fully understand why, but my conclusion is that any GCC(GNU Compiler Collection) is not possible to be installed via MacPorts in the usual way.

Fortunately I found a way around. It works!!! If you install the port py27-scipy, then GCC(GNU Compiler Collection), particularly gcc48, is going to be automatically installed. (see here.)

The versions of Xcode and MacPorts in my OS X Mavericks are

The proper version of MacPorts for Mavericks is required to be installed or re-installed.

Procedure in Bash shell (Terminal.app)

  1. Install Xcode command line tools.
    $xcode-select --install
    
  2. Update ports and install py27-scipy for gcc48 to be installed.1 Be patient. It takes about 2 hours.
    $sudo port selfupdate
    $sudo port install py27-scipy
    
  3. Set gcc to gcc48. gcc_select port is required. To see all variants of installed gcc, run the second line.2
    $sudo port install gcc_select
    $port select --list gcc
    $sudo port select gcc mp-gcc48
    $hash gcc
    $gcc --version
    

    10900062763_f192a02d82.jpg

  4. Clean up temporary files used in the middle of a port installation procedure.(Optional)3
    $sudo port -f uninstall inactive
    $sudo port -f clean --all all
    

HaPPy coding.

Epilog

Mavericks upgrade 후에 자동으로 깔리는 gcc는 적응이 안된다. C의 경우 options를 조정하면 어찌어찌 그 전에 짜 놓은 C codes를 돌릴 수도 있을 것 같기도 한데… 이렇게 돌린 계산 값의 신뢰도도 조금 우려되고… 어차피 Java나 Fortran을 돌리려면 GCC(GNU Compiler Collection)가 필요하다.

지난 Posts(OS X Mavericks, OS X Mavericks: list of compatible applications)에서 $sudo port selfupdate 가 먹히는 것만 보고 MacPorts가 동작한다고 썼는데, 제대로 쓰려면 현재(<2013-11-17 Sun>) 홈페이지에서 배포하는 MacPorts-2.2.1-10.9-Mavericks.pkg 를 받아 설치를 해야 한다. 그전 버전을 지울 필요는 없었다. 몇몇 ports가 깨져있어서 gcc48 같은 것이 바로 안 깔리는데, 지원자에 자원 봉사자들로 이루어진 MacPorts project를 욕할 생각은 없다. 오히려 고마울 뿐이며, py27-scipy 를 깔면 gcc48이 깔린다는 것을 알아낸 능력자 분께도 감사할 따름이다. Clang… Apple과 Google이 만든 compiler라… 이게 얼마나 좋은 지는 내가 평가할 수는 없지만, 나에게는 이 현상이 Apple이 끊임없이 보여주고 있는 지난 OS 지원 미비 혹은 중단 의 연장선으로 비춰진다.


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Footnotes:

1

See Ref. #1.

2

See Ref. #2 and #3.

3

See Ref. #4.

Created: 2013-11-17 Sun 10:36

Emacs 23.4.1 (Org mode 8.0.2)

Validate XHTML 1.0

No comments:

Post a Comment