C++11 on Mac with Clang or GCC

后端 未结 3 1044
陌清茗
陌清茗 2021-02-19 08:12

I have Xcode 4.5.2 on Moutain Lion, and I have install the lastest \"Command Line Tools\" but when I tried to compile with g++ or clang++ (and the opti

3条回答
  •  攒了一身酷
    2021-02-19 08:50

    I installed gcc-4.7 on my Mac to make C++11 work. GCC in its current version is fairly good at supporting C++11, so this should be a fair choice.

    The installation can be done by Homebrew and is not that complicated (at least I was able to do it...)

    To install Homebrew if you do not already have it:

    ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
    

    Now run

    brew doctor
    

    and fix whatever problems come up (there is something written in the hombrew documentation for that). Finally, install current gcc:

    brew install gcc
    

    If everything goes well you should be able to access g++-4.7, which allows -std=c++0x.

提交回复
热议问题