Cannot use OpenCV 2.4.9 in a CUDA 6 project with nvcc compiler on Mac OSX 10.9.4 (Bug #3911)


Added by Adrian Haarbach over 10 years ago. Updated over 10 years ago.


Status:Done Start date:2014-07-27
Priority:Normal Due date:
Assignee:Roman Donchenko % Done:

0%

Category:gpu (cuda)
Target version:2.4.10
Affected version:2.4.9 (latest release) Operating System:Mac OSX
Difficulty: HW Platform:x64
Pull request:

Description

I am trying to compile the simple cuda program below which includes opencv (and actually not any Cuda code)

#include <iostream>
//#include <cuda_runtime.h>
#include <opencv2/core/core.hpp>

using namespace std;

int main(int argc, char **argv)
{
    cout<<"Hello World:"<<endl;
    cout<<cv::Mat::eye(2,2,CV_32FC1)<<endl;
    cout<<"after opencv:"<<endl;

}

with nvcc -o cudatest cudatest.cu -lopencv_core

but it is giving me the error

/usr/local/include/opencv2/core/mat.hpp(117): error: type name is not allowed

/usr/local/include/opencv2/core/mat.hpp(117): error: identifier "_Atomic" is undefined

/usr/local/include/opencv2/core/mat.hpp(117): error: expected an expression

/usr/local/include/opencv2/core/mat.hpp(117): error: identifier "__c11_atomic_fetch_add" is undefined

/usr/local/include/opencv2/core/mat.hpp(286): error: type name is not allowed

This issues seems related to this resolved issue as well as this open issue but the details given there didn't really help me to figure out what I was supposed to do.

I installed opencv succesfully using homebrew and the --with-cuda flag (so it should have been compiled with libstdc++) after I slightly patched the formula
like in this thread

I tried to track down the error, so I used different compilers (clang++ and nvcc) as well as different setting (libc++ vs libstdc++) and got the following results: (just run compilertest.sh to test on your own)

_______1: 
clang++ -o cudatest cudatest.cu -lopencv_core -stdlib=libc++ -std=c++11 && ./cudatest
Hello World:
[1, 0;
  0, 1]
after opencv:

_______2:
clang++ -o cudatest cudatest.cu -lopencv_core -stdlib=libstdc++ -std=c++11 && ./cudatest
Hello World:" 

_______3:
nvcc -o cudatest cudatest.cu -lopencv_core
/usr/local/include/opencv2/core/mat.hpp(117): error: type name is not allowed

/usr/local/include/opencv2/core/mat.hpp(117): error: identifier "_Atomic" is undefined

/usr/local/include/opencv2/core/mat.hpp(117): error: expected an expression

/usr/local/include/opencv2/core/mat.hpp(117): error: identifier "__c11_atomic_fetch_add" is undefined

/usr/local/include/opencv2/core/mat.hpp(286): error: type name is not allowed

...'

_______4:
nvcc -o cudatest cudatest.cu --ptxas-options=-v -lopencv_core  -ccbin=clang++ -Xcompiler -std=c++11 -Xlinker -stdlib=libstdc++
/Developer/NVIDIA/CUDA-6.5/bin/../include/common_functions.h(145): warning: allowing all exceptions is incompatible with previous function "operator new(size_t)" 
/usr/include/c++/4.2.1/new(99): here

/Developer/NVIDIA/CUDA-6.5/bin/../include/common_functions.h(146): warning: allowing all exceptions is incompatible with previous function "operator new[](size_t)" 
/usr/include/c++/4.2.1/new(100): here

/usr/local/include/opencv2/core/mat.hpp(117): error: type name is not allowed

/usr/local/include/opencv2/core/mat.hpp(117): error: identifier "_Atomic" is undefined

/usr/local/include/opencv2/core/mat.hpp(117): error: expected an expression

/usr/local/include/opencv2/core/mat.hpp(117): error: identifier "__c11_atomic_fetch_add" is undefined

/usr/local/include/opencv2/core/mat.hpp(286): error: type name is not allowed

...'

compilertest.sh - script which tests the different compilers (2.2 kB) Adrian Haarbach, 2014-09-20 03:24 pm

cudatest.cu - the source file from above (249 Bytes) Adrian Haarbach, 2014-09-20 03:24 pm


Related issues

related to Bug #3469: CV_XADD breaks build in OSX10.9 Maverick + CUDA + clang Done 2013-12-30
related to Bug #3831: Cannot compile OpenCV 2.4.9 + CUDA 6 with clang on Mac OS... Open 2014-07-27

Associated revisions

Revision 5b3f89df
Added by Vadim Pisarevsky almost 10 years ago

Merge pull request #3911 from vpisarev:core_tweaks

History

Updated by Adrian Haarbach over 10 years ago

  • Status changed from Open to Done
  • Target version set to 2.4.10

Also available in: Atom PDF