2

In Visual C++ 8, I'm attempting to build the latest OpenCV release. I'm using the BUILD_ALL target which attempts to build both the debug and release versions of everything. I'm encountering a link error when it attempts to link the opencv_python application. The error is that the linker can't find the Python27_d.lib library which would be expected since I don't have that library, only the release library. What I don't understand is that it is the release library (without the _d) that is required in the project configuration and it is what is passed on the resulting command line.

Does VS add the _d by default if the debug version is being built. Is there a way to selectively turn it off for a given referenced library? BTW, the release version of the app builds fine.

sizzzzlerz
  • 4,277
  • 3
  • 27
  • 35
  • 1
    I believe you have to build a debug version of Python and create the Python27_d.lib yourself. It has to do with VC++ using two different runtime libraries depending on how code is compiled (Debug or Release). – martineau Feb 17 '13 at 17:42

1 Answers1

4

The problem is actually in Python.h ( and in particular pyconfig.h) which specifies the actual Python lib name

[I believe] you don't need to use a Python debug library, the boost people have already dealt with this problem

see Python debugging builds from pyconfig.h:

/* 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 */

in boost they have a wrapper boost/python/detail/wrap_python.hpp for Python.h which handles all the windows specific stuff ( and in particular allows you to build a debug dll with release Python.... maybe you can just try using that instead ( or go through the code;)

seanv507
  • 1,206
  • 1
  • 11
  • 23