【问题标题】:OpenCV program wouldn't compile on Visual Studio 2010OpenCV 程序无法在 Visual Studio 2010 上编译
【发布时间】:2014-08-16 12:29:23
【问题描述】:

我正在尝试在 Visual Studio 2010 中编译一个非常简单的 OpenCV (2.4.9) 程序,只是为了检查 opencv 库是否已正确链接。这是我要运行的程序代码。

#include "stdafx.h"
#include <stdio.h>
#include <opencv2/opencv.hpp>

using namespace cv;

int main(int argc, char** argv )
{
    Mat image;
    image = imread( "MyPic.jpg", 1 );

    if ( !image.data )
    {
        printf("No image data \n");
        return -1;
    }
    namedWindow("Display Image", CV_WINDOW_AUTOSIZE );
    imshow("Display Image", image);

    waitKey(0);

    return 0;
}

但是当我按下构建按钮时,编译失败并显示以下错误。

1>LINK : 致命错误 LNK1104: 无法打开文件 'opencv_gpu249.lib'

问题可能是什么?如何解决?

【问题讨论】:

  • 该库是如何进入您的链接器设置的? (预构建的 opencv 库不支持 gpu)
  • 我应该将哪些库文件添加到链接器设置中...
  • opencv_core249.lib opencv_highgui249.lib
  • 现在我收到此错误...1&gt;opencv_highgui249.lib(opencv_highgui249.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'我使用的是 64 位
  • 问题是您使用的是 x64 文件夹,但为 Win32 构建。 Debug 组合框旁边的组合框读取 Win32 而不是 x64。

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


【解决方案1】:

您需要将 OpenCV 库路径添加到 Visual Studio 的库目录

OpenCV-2.4.9-Path\build\x86\vc10\lib

或 64 位

OpenCV-2.4.9-Path\build\x64\vc10\lib

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-21
    • 2011-06-18
    • 2012-03-14
    • 2016-05-28
    • 1970-01-01
    • 2011-05-21
    相关资源
    最近更新 更多