我開始學習如何在c中使用opencv 3。當我在學習有關highgui.h功能,我想使用的功能cvCreateButton和我opencv 3:CVcreatebutton給LNK2019錯誤
得到了以下錯誤:
error LNK2019: unresolved external symbol _cvCreateButton referenced in function _main
我也得到:
error LNK1120: 1 unresolved externals
我使用visual studio 2013,在windows 10筆記本電腦上 這裏是源代碼:
#include <stdio.h>
#include <opencv2\core\core_c.h>
#include <opencv2\highgui\highgui_c.h>
#include <time.h>
int main(void)
{
int i,sliderVal = 0;
cvNamedWindow("Display window", CV_WINDOW_AUTOSIZE); //create a window
//create an image
IplImage* image = cvLoadImage("C:/Users/magshimim/Pictures/py.png", 1);
cvCreateTrackbar("test", "Display window", &sliderVal, 500, NULL);//trackbar without name
CvScalar color = { 0 };
color.val[3] = 255;//alpha value of 255
//make the square exactly in the middle of the picture
CvPoint p1 = cvPoint(image->width/4, image->height/4);//top left quarter of image
CvPoint p2 = cvPoint(p1.x * 3, p1.y * 3);//botton right quarter of image
cvCreateButton("button", NULL, "button", CV_PUSH_BUTTON, 0);//that is the line that gives the error
srand(time(NULL));//random seed
if (!image)//The image is empty.
{
printf("could not open image\n");
}
else
{
while (1)
{
for (i = 0; i < 3; i++)
{
color.val[i] = rand() % 256;//random color for square
}
//add square on picture, and update the screen
cvRectangle(image, p1, p2, color, -1, 0, 0);
cvShowImage("Display window", image);
cvWaitKey(sliderVal + 1);//slider sets the delay between each color change, delay of 0 is to wait forever so minimum delay is 1
}
cvWaitKey(0);
system("pause");
cvReleaseImage(&image);
}
return 0;
}
在項目屬性,我在添加C/C++ - >常規 - >附加包含目錄與所有的包含文件(opencv\build\include)
而且在鏈接的文件夾,在常規 - >產生額外庫目錄,我增加C:\opencv\build\x86\vc11\bin and C:\opencv\build\x86\vc12\lib
而在input-> additional dependencies中,我添加了opencv_world300d.lib
和opencv_ts300d.lib
。
我從c老師那裏得到了關於編程的課後課程/活動的指導。該指令是在希伯來文,但這裏是鏈接如果有人想看看
https://drive.google.com/open?id=0Bxa6_LIMELY4RjVvVDJGZkNRZ1k
我下載的OpenCV從這裏:http://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0/opencv-3.0.0.exe/download。
即使我將opencv_highgui300d.lib
添加到鏈接器 - >輸入 - >附加依賴項,它不能解決問題。 我該如何解決它? 什麼導致了錯誤? 諾姆·懷斯曼
謝謝你的回答。我忘了說我已經將opencv \ build \ x86 \ vc12 \ bin添加到路徑中了.FILL路徑是什麼? –
對不起,這是我打算完成的拼寫錯誤。 –
我最終將dll一個接一個地複製到了我的項目構建文件夾中。 –