2012-11-23 34 views
0

可能重複:
OpenCV: link error, can’t resolve external symbol _cvResize and _cvCvtColor
What is an undefined reference/unresolved external symbol error and how do I fix it?OpenCV的安裝,未解決的外部符號

我已經嘗試了所有在其網站上提供的教程,和計算器的解決方案,但我仍然找不到解決方案。

我已經做過的事情:

1-添加了include頭文件夾。

2-加入lib文件夾到附加lib目錄

3-加入opencv_core243d.lib和opencv_highgui243d.lib到附加的依賴性。

代碼我試圖編譯:

#include <stdio.h> 
#include <cv.h> 
#include <highgui.h> 


int main(int argc, char* argv[]) 
{ 
if (argc < 2) 
{ 
    printf("Usage: ./opencv_hello <file.png>\n"); 
    return -1; 
} 

    IplImage* img = cvLoadImage(argv[1], CV_LOAD_IMAGE_UNCHANGED); 
if (!img) 
{ 
    return -1; 
} 
cvNamedWindow("display", CV_WINDOW_AUTOSIZE); 
    cvShowImage("display", img); 

    cvWaitKey(0);   

    return 0; 
} 

的連接提供了關於懸而未決的符號,如cvLoadImage,cvWaitKey等 我能想到的唯一的事情將是庫的錯誤,但我已經包括他們已經。

+0

@BoPersson也試過,同樣的錯誤 –

回答

1

據我所知,您正在使用OpenCV的2.4

在這種情況下,我想使用C++接口的建議。

#include <stdio.h> 
#include <opencv2/core/core.hpp> 
#include <opencv2/highgui/highgui.hpp> 

int main(int argc, char* argv[]) 
{ 

if (argc < 2) 
{ 
    printf("Usage: ./opencv_hello <file.png>\n"); 
    return -1; 
} 

cv::Mat img = imread(argv[1]); 
if (img.empty()) 
{ 
    return -1; 
} 

imshow("display", img); 

waitKey(0); <---- cvWaitKey() is a C interface functio, waitKey() - C++ 

return 0; 
} 
+0

這樣做後,我仍然得到相同的鏈接器錯誤。 –

+0

@BartlomiejLewandowski上哪一個函數? – Alex

+0

現在在!img,沒有找到以cv :: Mat作爲操作數的操作符 –