Can't compile code samples (CUDA 5.5, Macbook Pro, OS X 10.8)

I’ve just installed the CUDA Toolkits for the first time on a retina Macbook pro. I followed the instructions in http://developer.download.nvidia.com/compute/cuda/5_5/rel/docs/CUDA_Getting_Started_Mac.pdf , but when running ‘make’ in my writeable copy of the examples folder, I get this:

$ make
/Developer/NVIDIA/CUDA-5.5/bin/nvcc -ccbin g++ -I../../common/inc  -m64 -Xcompiler -arch -Xcompiler x86_64   -gencode arch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=\"sm_35,compute_35\" -o asyncAPI.o -c asyncAPI.cu
cc1plus: error: unrecognized command line option "-arch"
make[1]: *** [asyncAPI.o] Error 1
make: *** [0_Simple/asyncAPI/Makefile.ph_build] Error 2

Can anyone suggest what’s going wrong, and how I can fix it?

I can build this sample on x86/64 on Mac OS X 10.8.

This is what “g++ --version” reports on my system:

i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Can you check your system? Looks like it is picking a different compiler.

Do you have a beta version of XCode installed?

@eugeneo

Ok, it seems the problem is related to having the Macports g++ installed:

$ g++ --version
g++ (MacPorts gcc45 4.5.4_7) 4.5.4
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Keeping the Macports g++ installed is important to me - is there a way to temporarily switch back to the system version to build the examples?

XCode is “Version 4.6.3 (4H1503)” (not beta).

Speaking of XCode, I’d prefer to build the examples in XCode rather than from the command line - is there a way to do that?

Answering my own question:

I can switch to the system gcc/g++ using

sudo port select --set gcc llvm-gcc42
hash -r

and switch back with

sudo port select --set gcc mp-gcc47
hash -r

The command to see the list of installed versions is port select --list gcc.

The examples are compiling now, and it looks like there are no problems. It would still be nice to know if there’s a way to build them from within XCode.

Hi, I have exactly the same problem, would you mind explaining to me what you did so it works?
Than kyou!