Ask Your Question

OpenCV + CUDA + OSX 10.9

asked 2013-10-28 00:13:30 -0500

josericardojr gravatar image

updated 2013-11-04 01:17:43 -0500

jensenb gravatar image

After updating my OSX to 10.9 (Maverick), I cannot compile OpenCV with CUDA support. I was able to install the CUDA SDK and compile and run all samples, so it is not a CUDA problem.

I receive the following error:

[ 22%] Built target IlmImf
[ 22%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./
clang: error: unsupported option '-dumpspecs'
clang: error: no input files 
CMake Error at (message):
Error generating/Users/josericardo/Downloads/opencv-

Does anyone have this problem? I've searched on the net about this specific error (some suggestions for previous error like this do exist but not for this one), but without success.

Thanks so much!

edit retag flag offensive close merge delete


Have you installed the CUDA 5.5 SDK specific for 10.9?

jensenb gravatar imagejensenb ( 2013-11-03 14:20:55 -0500 )edit

3 answers

Sort by ยป oldest newest most voted

answered 2013-11-04 01:15:19 -0500

jensenb gravatar image

updated 2013-12-03 08:39:19 -0500

This is most likely caused by an incorrect setting of CUDA_HOST_COMPILER in the CMake settings. By default OpenCV chooses /usr/bin/cc (an alias for /usr/bin/clang), but this is unrecognized by the NVidia host compiler driver and hence the inappropriate compiler flags that are being passed to clang. The fix is simple: just change CUDA_HOST_COMPILER to /usr/bin/clang and everything should work just fine. Also make sure you have installed the updated version of the CUDA 5.5 Toolkit specific for 10.9.

EDIT: I should note that Cuda will most likely not work for 10.9 because Cuda uses libstdc++, whereas most packages link to libc++ by default. I suggest opening a bug report a the Cuda developer zone to raise awareness of the issue: developer zone

edit flag offensive delete link more

answered 2014-01-28 12:20:00 -0500

mbertini gravatar image

I've always struggled a bit while trying to compile OpenCV with CUDA on my OSX machine. Basically this was due to the fact that Apple has started since some time to move toward clang rather than sticking to g++, that was the preferred compiler in CUDA: Luckily the latest CUDA SDK (5.5) uses also clang, so now it's much easier to compile everything using this nice compiler.

Here's how I compiled OpenCV 2.4.8 on OSX Mavericks 10.9.1 using Xcode 5.0.2 and CUDA 5.5:

  • open CMake to set the project, and to the basic configuration in latest Xcode (I think >= 5) there's no more the gcc compiler, deprecated in favor of clang, so go to the CUDA options of the CMAKE project and change CUDA_HOST_COMPILER to use "/usr/bin/clang".
  • Apparently CUDA 5.5 supports only the older libstdc++ library and not the more modern libc++, so update CUDA_NVCC_FLAGS to tell nvcc to tell the native compilar to use this older library. Add "-Xcompiler -stdlib=libstdc++; -Xlinker -stdlib=libstdc++"
  • Tell also the C++ compiler that compiles the rest of the library to use libstdc++: show the advanced options of CMAKE and go to CMAKE to add "-stdlib=libstdc++" to both CMAKE_CXX_FLAGS and CMAKE_EXE_LINKER_FLAGS
edit flag offensive delete link more


While cuda is linked against libstdc++, that doesn't mean it couldn't be used against apps that use libc++, both standard libraries can peacefully coexist in the same app. You would just have to make sure that all the cuda is in a separate library, and that the library does not make use c++ classes that live in std. This is the problem with OpenCV, their CUDA functions take c++ classes from the standard library (string for example), thus preventing the library from safely coexisting libc++ code.

jensenb gravatar imagejensenb ( 2014-01-28 12:30:07 -0500 )edit

Without using libstdc++ also for the rest of OpenCV there was a problem in compiling the CUDA library. Without the last bullet point I've written the compilation did not complete successfully.

mbertini gravatar imagembertini ( 2014-01-29 05:12:39 -0500 )edit

answered 2013-11-03 00:07:01 -0500

Jenniferwillow gravatar image

I just ran into exactly the same problem. It also happens when you try to compile the CUDA samples.

edit flag offensive delete link more

Question Tools


Asked: 2013-10-28 00:13:30 -0500

Seen: 2,601 times

Last updated: Jan 28 '14