• VS2010自行编译OpenCV2.4.4时缺少python27_d.lib的解决方法


      错误 24 error LNK1104: 无法打开文件“python27_d.lib”  C:OpenCVVS2013_64modulespythonLINK opencv_python

    编译环境概述:

      1、IDE:Visual Studio C++2010,debug win32;

      2、OpenCV版本:opencv-2.4.4.tar.gz(源代码);

      3、CMake版本:cmake-2.8.8-win32-x86.exe。

     方法1:

      错误的原因是系统安装有Python2.7,而默认的情况下Python是不提供python27_d.lib和python27_d.dll文件的。为了编译通过,需要在网上下载此二文件。下载地址请点击这里

      将下载的lib文件置于C:Program Files (x86)Microsoft Visual Studio 10.0VClib,dll文件置于C:Program Files (x86)Microsoft Visual Studio 10.0VCin,编译通过。

     方法2:

      一个妥协的方法是注释掉会使用python27_d.lib部分的代码,替换为使用python27.lib

       具体做法如下:

      在OpenCV项目的bindings中的opencv_python项目中,点击“外部依赖项”,在其中找到pyconfig.h和object.h文件,如下图所示:

      在pyconfig.h中,将

    #ifdef _DEBUG  
    #   define Py_DEBUG  
    #endif  

      修改为:

    #ifdef _DEBUG  
    //# define Py_DEBUG  
    #endif  

      将

    /* For an MSVC DLL, we can nominate the .lib files used by extensions */  
    #ifdef MS_COREDLL  
    #   ifndef Py_BUILD_CORE /* not building the core - must be an ext */  
    #       if defined(_MSC_VER)  
                /* So MSVC users need not specify the .lib file in 
                their Makefile (other compilers are generally 
                taken care of by distutils.) */  
    #           ifdef _DEBUG  
    #               pragma comment(lib,"python27_d.lib")  
    #           else  
    #               pragma comment(lib,"python27.lib")  
    #           endif /* _DEBUG */  
    #       endif /* _MSC_VER */  
    #   endif /* Py_BUILD_CORE */  
    #endif /* MS_COREDLL */ 

      修改为

    /* For an MSVC DLL, we can nominate the .lib files used by extensions */  
    #ifdef MS_COREDLL  
    #   ifndef Py_BUILD_CORE /* not building the core - must be an ext */  
    #       if defined(_MSC_VER)  
                /* So MSVC users need not specify the .lib file in 
                their Makefile (other compilers are generally 
                taken care of by distutils.) */  
    #           ifdef _DEBUG  
    #               pragma comment(lib,"python27.lib")  
    #           else  
    #               pragma comment(lib,"python27.lib")  
    #           endif /* _DEBUG */  
    #       endif /* _MSC_VER */  
    #   endif /* Py_BUILD_CORE */  
    #endif /* MS_COREDLL */  

      在object.h中,将

    /* Py_DEBUG implies Py_TRACE_REFS. */  
    #if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)  
    #define Py_TRACE_REFS  
    #endif  

      修改为

    /* Py_DEBUG implies Py_TRACE_REFS. */  
    #if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)  
    //#define Py_TRACE_REFS  
    #endif  

    保存之后,再次编译就成功啦!

    参考链接:

    1、编译OpenCV缺少python27_d.lib的解决方法

    2、opencv:fatal error LNK1104: 无法打开文件“python26_d.lib” 问题解决

  • 相关阅读:
    System.Web.Mvc.HttpPostAttribute vs System.Web.Http.HttpPostAttribute? [duplicate]
    Autofac Exception Summary Autofac异常汇总
    AppBox v1.0 发布了
    [原创]ExtAspNet秘密花园(十一) — 布局概述
    ExtAspNet v3.1.9
    ExtAspNet v3.1.8 发布了
    ExtAspNet 主题赏析 7款 超炫!
    ExtAspNet v3.1.7
    ExtAspNet v3.1.6
    [原创]采用Asp.Net的Forms身份验证时,持久Cookie的过期时间会自动扩展
  • 原文地址:https://www.cnblogs.com/rainbow70626/p/9071687.html
Copyright © 2020-2023  润新知