Saturday, December 1, 2012

nvcc, OS X, clang, and dumpspecs

If you are building with nvcc on OS X and get errors along the lines of "clang error: unsupported option '-dumpspecs'" - welcome to the new build world.

The best fix I've found so far is to replace the /usr/bin/cc and /usr/bin/c++ symlinks (which currently go to clang) with symlinks to llvm-gcc.

sudo rm /usr/bin/cc
sudo rm /usr/bin/c++
sudo ln /usr/bin/llvm-gcc /usr/bin/cc
sudo ln /usr/bin/llvm-g++ /usr/bin/c++

Try that out and see if it works!  Please let me know if you find a better solution as well.

4 comments:

  1. Are you using CMake 2.8-10?

    I just encountered this error for the first time after configuring a new iMac with CMake 2.8-10 and CUDA 5.0.

    I switched back to CMake 2.8-8, which I was using on a different Mac, and the error went away.

    Note that the above "best fix" switches the compilers from clang to the older Apple compilers.

    ReplyDelete
    Replies
    1. Ken: Cmake 2.8.10 is the first CMake version to respect cc and c++ as the default compilers on Mountain Lion. Previous version would use gcc and g++ on the Mac.

      Delete
  2. A better solution is make .. -DCMAKE_C_COMPILER=/usr/bin/llvm-gcc -DCMAKE_CXX_COMPILER=/usr/bin/llvm-g++

    ReplyDelete
  3. James soln did not work for me.. still stuck on opencv

    ReplyDelete