3

I just suffer a problem that the all the things works well on my ubuntu. However, I want to get things work on my mac, bad thing happens. it shows the following errors

cc1plus: error: unrecognized command line option "-std=c++0x"

I am total new to mac stuff, I got the xcode 4 installed. I guess there must be c++0x, but I wonder how can i configure it with waf.

Thanks a lot!!

Monkey_Taolun
  • 49
  • 1
  • 6

3 Answers3

2

As Xcode comes with Clang on mac you can get c++0x support if you configure waf to use Clang.

In your wscript add to configure:

def configure( conf ):
    ...
    conf.env.CXXFLAGS = [ '-std=c++0x', '-stdlib=libc++' ]
    conf.env.LINKFLAGS = [ '-std=c++0x', '-stdlib=libc++' ]
    ....

Then run waf as:

CXX=clang++ waf configure
CXX=clang++ waf build
stefanB
  • 77,323
  • 27
  • 116
  • 141
2

I’m guessing you’re using GCC supplied with Xcode. That’d be GCC 4.2.1, a rather old version that won’t be updated by Apple in the foreseeable future.

You have essentially two options:

  • Xcode ships Clang/LLVM besides GCC, so you could use Clang/LLVM instead. That -std=c++0x option is recognised by Clang/LLVM but C++0x is not as fully supported as in recent versions of GCC. The LLVM project keeps a page listing their current C++0x support status.

  • Use a more recent version of GCC. You can either compile it locally or install it via one the open source package managers available on Mac OS X: MacPorts, Fink, Homebrew. I don’t really know if and which versions of GCC they’re able to build, so check with them first.

  • Also, it could be the case that waf itself is already available in those package managers. –  Apr 19 '11 at 23:54
1

On Mac you can't go wrong with clang. You'll have to build the compiler yourself (using e.g. gcc-4.2 that you already have). It has -std=c++0x. The support for it isn't complete, but it is growing all the time. On the Mac you might also look at libc++ for C++0x support (combined with clang).

Howard Hinnant
  • 206,506
  • 52
  • 449
  • 577