opencv 3:CVcreatebutton 给出 LNK2019 错误

opencv 3: CVcreatebutton gives LNK2019 error

我开始学习在 c 中使用 opencv 3。当我学习 highgui.h 函数时,我尝试使用函数 cvCreateButton 并且

出现以下错误:

error LNK2019: unresolved external symbol _cvCreateButton referenced in function _main

我还得到了:

error LNK1120: 1 unresolved externals

我在 windows 10 笔记本电脑上使用 visual studio 2013 这是源代码:

#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++->general->Additional Include directories 包含所有包含文件的文件夹 (opencv\build\include)

并且在 linker 中,在 general->additonal 库目录中我添加了 C:\opencv\build\x86\vc11\bin and C:\opencv\build\x86\vc12\lib

并且在输入->附加依赖项中我添加了 opencv_world300d.libopencv_ts300d.lib.

我在放学后 class/activity 从我的 c 语言老师那里得到了关于 c 语言编程的指导。说明是希伯来语的,但如果有人想看

,这里是link

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 添加到 linker->input->additional dependencies 也不能解决问题。 我该如何解决? 是什么导致了错误? 诺姆·怀斯曼

您需要将 opencv/bin/Release opendcv/bin/Debug 添加到您的路径 - 您需要包含 完整 路径,如果您在路径中有空格,请使用引号路径名。另一种方法是将所需的 dll 复制到解决方案的 Release 和 Debug 文件夹中。这些 dll 与您在依赖项中包含的库具有相同的基本名称。