【问题标题】:opencv vs 2010 dependencies issueopencv vs 2010 依赖问题
【发布时间】:2013-07-28 17:23:15
【问题描述】:

我在尝试在 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:\ 驱动器,所以那里应该没有任何问题。我提前感谢大家的帮助!

【问题讨论】:

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


    【解决方案1】:

    只需替换:

    opencv_highgui243.lib
    

    开:

    opencv_highgui243d.lib
    

    【讨论】:

    • OP 正在使用 OpenCV 2.4.6。
    • 好的,我尝试将所有调试 .lib 移动到一个单独的文件夹中,然后将其他依赖项设置到调试文件夹。我仍然遇到同样的错误。我仍然会尝试在 vs 中四处寻找,看看我是否遗漏了任何东西。我还应该注意“链接器”>>“输入”区域中的其他依赖项中的任何内容吗?再次感谢
    • 哦,没关系,我发现库的目录也有问题,但你确实帮助了我很多调试与发布库。谢谢:-)
    【解决方案2】:

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

    因为你已经构建了debug模式,所以库也应该是debug版本,比如:

    opencv_highgui243d.lib
    

    而不是

    opencv_highgui243.lib
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-06-01
      • 2019-11-24
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多