opencv vs 2010依赖项问题

时间:2013-07-28 17:23:15

标签: c++ visual-studio-2010 opencv include

我在尝试使用64位Windows 8机器上的visual studio ultimate 2010设置opencv 2.4.6时出现问题。我知道要添加include和dll引用,但是当我执行代码时,我会显示这个巨大的外部链接错误:

代码:

#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, const char** argv )
{
   Mat img = imread("mypic.JPG", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the            file "MyPic.JPG" and store it in 'img'

  if (img.empty()) //check whether the image is loaded or not
  {
      cout << "Error : Image cannot be loaded..!!" << endl;
      //system("pause"); //wait for a key press
      return -1;
  }

  namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
  imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window

  waitKey(0); //wait infinite time for a keypress

  destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"

  return 0;
}

,错误是:

1>Build started 7/28/2013 3:08:34 AM.
1>InitializeBuildStatus:
1>  Touching "Debug\opencv_2.0.unsuccessfulbuild".
1>ClCompile:
1>  All outputs are up-to-date.
1>ResourceCompile:
1>  All outputs are up-to-date.
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>core.obj : error LNK2019: unresolved external symbol "void __cdecl       cv::destroyWindow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?destroyWindow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>core.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z) referenced in function _main
1>core.obj : error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV_InputArray@1@@Z) referenced in function _main
1>core.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray@cv@@QAE@ABVMat@1@@Z)   referenced in function _main
1>core.obj : error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class std::basic_string<char,struct std::char_traits<char>,class     std::allocator<char> > const &,int)" (?namedWindow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main
1>core.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread@cv@@YA?AVMat@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main
1>core.obj : error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree@cv@@YAXPAX@Z) referenced in function "public: __thiscall cv::Mat::~Mat(void)" (??1Mat@cv@@QAE@XZ)
1>core.obj : error LNK2019: unresolved external symbol "public: void __thiscall   cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QAEXXZ) referenced in function "public:   void __thiscall cv::Mat::release(void)" (?release@Mat@cv@@QAEXXZ)
1>core.obj : error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd@cv@@YAHPAHH@Z) referenced   in function "public: void __thiscall cv::Mat::release(void)" (?release@Mat@cv@@QAEXXZ)
1>C:\Users\Parker\documents\visual studio 2010\Projects\opencv_2.0\Debug\opencv_2.0.exe : fatal error LNK1120: 9 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.67
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我确实尝试在其他依赖项中添加.lib文件,但vs2010表示它没有检测到它们,因为我确实看到了另一篇文章,就像我的一样。 include目录包括通用“include”文件夹以及opencv和opencv2文件夹。然后我将build \ x64 \ vc10 \ lib,bin和staticlib添加到其他lib目录中。 opencv也被提取到c:\驱动器,所以那里不应该有任何问题。我提前感谢大家的帮助!

2 个答案:

答案 0 :(得分:2)

只需替换:

opencv_highgui243.lib

在:

opencv_highgui243d.lib

答案 1 :(得分:1)

可能您已经包含了发布库而不是调试版本。

由于您已内置debug模式,因此库也应为debug版本,如:

opencv_highgui243d.lib

而不是

opencv_highgui243.lib