zoukankan      html  css  js  c++  java
  • 缺少Python27_d.lib的解决方法

    缺少Python27_d.lib的解决方法

    http://blog.csdn.net/junparadox/article/details/52704287

    http://lib.csdn.net/base/python  

    简介

    最近在调用caffe的Python接口训练网络,需要进到caffe代码中调试,编译时需要用Python27_d.lib、Python27_d.dll。但是一般我们下载的都是release版的。怎么办?自己编译一个debug版本当然可以,但是很麻烦啊。很多网友解决方法是把Python27.lib、Python27.dll拷贝为Python27_d.lib、Python27_d.dll。 
      不过拷贝后可能出现一些错误。这里说一下我的解决方法。

    在vs下引用伪造的”debug版本“可能出现链接问题

      引用自己伪造的debug版Python27_d.lib、Python27_d.dll可能出现的问题:

    1. extmodule.obj : error LNK2019: unresolved external symbol __imp___Py_Dealloc referenced in function _PySwigObject_format
    2. extmodule.obj : error LNK2019: unresolved external symbol __imp___Py_NegativeRefcount referenced in function _PySwigObject_format
    3. extmodule.obj : error LNK2001: unresolved external symbol __imp___Py_RefTotal
    4. extmodule.obj : error LNK2019: unresolved external symbol __imp___PyObject_DebugFree referenced in function _PySwigObject_dealloc
    5. extmodule.obj : error LNK2019: unresolved external symbol __imp___PyObject_DebugMalloc referenced in function _PySwigObject_New
    6. extmodule.obj : error LNK2019: unresolved external symbol __imp__Py_InitModule4TraceRefs referenced in function _init_extmodule

    主要是因为 Py_DEBUG/Py_TRACE_REFS 引起, 修改 Pythoninclude 下的 pyconfig.h, object.h

    解决方法

    • 修改 pyconfig.h

    #ifdef _DEBUG
    # define Py_DEBUG
    #endif

    #ifdef _DEBUG
    //# define Py_DEBUG
    #endif

    修改

    # ifdef _DEBUG
    # pragma comment(lib,"python27_d.lib")
    # else
    # pragma comment(lib,"python27.lib")
    # endif /* _DEBUG */

    # ifdef _DEBUG
    # pragma comment(lib,"python27.lib")
    # else
    # pragma comment(lib,"python27.lib")
    # endif /* _DEBUG */

    修改object.h

    #if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)
    #define Py_TRACE_REFS
    #endif

    为:

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

  • 相关阅读:
    [leetcode]_Search Insert Position
    [leetcode]_Merge Two Sorted Lists
    [leetcode]_Valid Parentheses
    喧闹中坚守底线-徘徊的行走在不知道路在何方的大地上。
    [leetcode]_Longest Common Prefix
    [leetcode]_Remove Nth Node From End of List
    [leetcode]_Roman to Integer
    [leetcode]_Palindrome Number
    策略模式(Strategy)
    面向对象
  • 原文地址:https://www.cnblogs.com/sggggr/p/12623317.html
Copyright © 2011-2022 走看看