2013-12-16 119 views
3

我有一个错误,当我编译我的程序,它使用了OpenCV只是其中的#include,这就是:OpenCV的铛mat.hpp错误:调用成员函数“PTR”不明确

In file included from /usr/local/include/opencv2/highgui/highgui.hpp:46: 
In file included from /usr/local/include/opencv2/core/core.hpp:4826: 
/usr/local/include/opencv2/core/mat.hpp:2248:42: error: call to member function 'ptr' is ambiguous 
{ return (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); } 
        ~~~~~~~~~~~~~~~~~~~~^~~ 
/usr/local/include/opencv2/core/core.hpp:3507:12: note: candidate function 
    uchar* ptr(int i0, bool createMissing, size_t* hashval=0); 
     ^
/usr/local/include/opencv2/core/core.hpp:3509:12: note: candidate function 
    uchar* ptr(int i0, int i1, bool createMissing, size_t* hashval=0); 
     ^
/usr/local/include/opencv2/core/core.hpp:3513:12: note: candidate function not viable: no known conversion from 'int' to 
     'const int *' for 1st argument; take the address of the argument with & 
    uchar* ptr(const int* idx, bool createMissing, size_t* hashval=0); 
     ^
/usr/local/include/opencv2/core/core.hpp:3511:12: note: candidate function not viable: requires at least 4 arguments, but 3 were 
     provided 
    uchar* ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0); 

我试过多次(最近)版本的OpenCV,但在我的情况下,他们都没有工作。 OpenCV是否正式不支持Clang,还是我应该报告的错误? 我使用的是Linux(ubuntu 13.04),我使用了clang 3.2-1。

+0

好的,所以我认为我们可以说OpenCV并不完全支持Clang(并且根本不支持)。 – Athanase

回答

-2

我最近在我的Mac上得到了同样的错误。 (扬-2016)

获得错误的步骤如下:

  1. 使用BREW brew install opencv 在这种情况下安装OpenCV,酿造安装OpenCV的前gcc和使用gcc不铛编译OpenCV的。 gcc安装在/usr/local/Cellar/gcc/5.3.0/bin/

  2. 我做了我的程序,并尝试使用默认选项与CMake编译。 cmake试图使用clang作为编译器:它的位置是/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

  3. 因为opencv的编译器和程序的编译器不同,所以会产生错误。

所以,我想在CMake的设置编译器GCC为 set(CMAKE_C_COMPILER /usr/local/Cellar/gcc/5.3.0/bin/gcc-5) set(CMAKE_CXX_COMPILER /usr/local/Cellar/gcc/5.3.0/bin/gcc-5)

然后,我通过了错误。

相关问题