Puzzling dependency of Boost.Python 1.54 (debug build) to Python27.lib on Windows

前端 未结 2 964
栀梦
栀梦 2021-01-13 12:23

I must be doing some kind of obvious mistake but after hours of fighting I\'m unable to make further progress:

After upgrading to Boost 1.54, CMake 2.8.12 and Python

2条回答
  •  攒了一身酷
    2021-01-13 13:09

    I fixed the problem, thanks to hints found in this post: Visual C++ debug library naming convention.

    Basically, the header file pyconfig.h that ships with Python (in C:\Python27\include\) forces linking to python27_d.lib in Debug build (via a #pragma comment() directive), regardless of whether this library exists or not.

    The trick is to never include Python.h directly, but instead to include Boost's wrapper for that file, boost/python/detail/wrap_python.hpp which takes care of disabling the offending #pragma comment() directive.

提交回复
热议问题