c++ - opencv vs 2010 依赖问题

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

我在尝试在 64 位 Windows 8 计算机上使用 Visual Studio Ultimate 2010 设置 opencv 2.4.6 时遇到问题。我知道要添加包含和 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:\驱动器,因此那里应该不会有任何问题。我预先感谢大家的帮助!

最佳答案

只需替换:

opencv_highgui243.lib

关于:

opencv_highgui243d.lib

关于c++ - opencv vs 2010 依赖问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17910802/

相关文章:

c++ - 为 arm 设置 visual studio express

c++ - QLibraryInfo 似乎没有加载 qt.conf

c++ - Doxygen 基类有时无法解析

visual-studio-2010 - 安装 Visual Studio 2010(任何版本)只会在 C++ 头文件目录中安装 2 个文件

c# - Subversion 和 Visual Studio 项目的最佳实践

c++ - 用图像或视频填充 OpenCV (OpenFrameworks) 中的 Blob

python - 模板使用opencv匹配屏幕截图

python - 用opencv加载视频

c++ - 如何获取 map 值的引用?

C++ 声明式解析序列化