2013-12-16 118 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)

然後,我通過了錯誤。

相關問題