【问题标题】:error LNK2019 and LNK1120 while using openCV使用 openCV 时出现错误 LNK2019 和 LNK1120
【发布时间】:2014-01-15 08:32:54
【问题描述】:

我从讲师那里得到了一个程序,这里是代码:

#include <iostream>
#include <opencv2/opencv.hpp>
int main(int argc, char* argv[])
{
printf("Hit ESC key to quit ...\n");
cv::VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) { // check if we succeeded
printf("error ‐ can't open the camera\n");
system("PAUSE");
return 1;
}
double WIDTH = cap.get(CV_CAP_PROP_FRAME_WIDTH);
double HEIGHT = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
printf("Image width=%f, height=%f\n", WIDTH, HEIGHT);
// Create image window named "My Image". (You actually don't have to do
// this step, but this command allows you to set properties of the window,
// such as its location, or whether you can resize it.)
cv::namedWindow("My Image");
// Allocate images
cv::Mat imgInput(
cv::Size(WIDTH,HEIGHT), // specify size
CV_8UC3, // specify type: CV_8UC3=8bit, unsigned, 3 channels
cv::Scalar(0)); // initialize to this value (optional)
// Run an infinite loop until user hits the ESC key
while (1) {
cap >> imgInput; // get image from camera
// Show the image in the window
cv::imshow("My Image", imgInput);
// wait for x ms (0 means wait until a keypress)
if (cv::waitKey(1) == 27)
break; // ESC is ascii 27
}
return EXIT_SUCCESS;
}

但是当我编译时收到这些错误

错误 LNK2019:未解析的外部符号 __CrtDbgReportW 在函数“void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)”(?_Debug_message@std@@YAXPB_W0I@Z) C:\Users\LENOVO \Desktop\Tugas\Smst6\Citra\lab2\lab2\libcpmtd.lib(stdthrow.obj) lab2

error LNK1120: 1 unresolved externals C:\Users\LENOVO\Desktop\Tugas\Smst6\Citra\lab2\Debug\lab2.exe 1 1 lab2

我使用 Visual Studio 2010 和 openvc 2.4.8

【问题讨论】:

  • opencv2/opencv.hpp 中有什么?

标签: c++ opencv


【解决方案1】:

查看msdn的描述error LNK2019,我在应用程序开发时也遇到过这种错误,经过简要分析,在项目的vcxprojs文件中也发现了错误,在我的情况下它已损坏。在使用代码之前,您是否在您的机器上完成了 Opencv 的设置。如果是,那么可能与vcxproj 有关。如有更多问题,请告诉我。

【讨论】:

    【解决方案2】:

    您是否使用 CMake 进行构建和配置?如果是这样,您可能需要修改它以包含库。 对于 lnk1120 错误,请检查您的附加依赖项,您可能错过了一个库。

    lnk1120 MSDN

    lnk2019 MSDN

    另见 - I'm getting LNK2019 errors using SDL 2.0.1 in Visual Studio 2013

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-04
      • 1970-01-01
      • 2014-01-19
      • 2014-09-06
      • 2011-10-25
      • 1970-01-01
      相关资源
      最近更新 更多