OpenCV + CUDA + OSX (10.8.3)

asked 2013-05-20 06:00:05 -0500

Hansg91 gravatar image

updated 2013-05-20 14:11:10 -0500


I have been trying to compile OpenCV with CUDA (5.0) enabled on OSX 10.8.3, but ran into some problems.

First compiling it gave me some flag error that could not be found. Apparently CUDA and clang don't go well together. I changed CUDA_HOST_COMPILER to point to my gcc-4.7 binary, but apparently gcc 4.7 and CUDA don't go well together either. After installing gcc-4.5 and letting CUDA compile with that I get a lot further, I then got a lot of errors about uint being undefined, so I defined unsigned as uint in common.hpp. That seemed to fix my CUDA problems, after a long time it continued compiling cpp code and it got stuck linking libopencv_gpu.dylib. I get the following linking error :

Undefined symbols for architecture x86_64:
  "std::ctype<char>::_M_widen_init() const", referenced from:
      stdDebugOutput(cv::String const&) in
ld: symbol(s) not found for architecture x86_64

I googled this error and could not find many solutions. One solution was to install gcc as universal, which allows it to compile 32 bit too I believe, but this did not fix my error. ps. for clarification, this error is after it is done compiling cuda code and is back to compiling opencv with clang.

ps2. Compiling opencv with gcc is not an option I think since I am using it in ROS and ROS on OSX can pretty much only be compiled with clang.

Thanks in advance!

ps. I tried opencv 2.4.3 and opencv 2.4.5, same result.

edit: building as DEBUG seems to fix this issue, not sure why... if anyone can explain me why or how to properly build in release, I would be very interested.

edit retag flag offensive close merge delete


I spent a couple of days trying to do the same on my macbook in OS 10.8... I ended up installing Ubuntu and doing it from there (was much easier with less bugs and errors). Good luck!

basheer gravatar imagebasheer ( 2013-05-20 21:50:52 -0500 )edit

Actually I managed to compile everything now. I ended up adding the flag -fno-inline which apparently solved this issue.

Hansg91 gravatar imageHansg91 ( 2013-05-23 05:46:23 -0500 )edit

hmmm... interesting... are you sure everything worked? Did u compile stuff that use gpu module? Oh, well. I probably messed something up back then (I'm working on Ubuntu now and it works easier, I think)

basheer gravatar imagebasheer ( 2013-05-25 23:24:57 -0500 )edit

Yes even gpu stuff is working, I have been working with the gpu version of warpAffine and detectCascades for a while now :) It is sometimes rather complicated to get something to work natively on OSX, but in my opinion it pays off by not having to use parallels or something.

Hansg91 gravatar imageHansg91 ( 2013-05-26 09:44:49 -0500 )edit

I'm having the same problem (and in another machine with ubuntu is easy to resolved too but I still want to compile it in Mac). How did you add that flag? in cmake?

nkint gravatar imagenkint ( 2013-05-29 05:22:04 -0500 )edit

Yes in cmake (ccmake to be precise). I added it in CMAKE_CXX_FLAGS. You have to enable advanced mode for that setting to appear. Good luck!

Hansg91 gravatar imageHansg91 ( 2013-05-29 05:39:46 -0500 )edit