简体   繁体   中英

Boost.Python examples, Windows 7 x64, “ImportError: DLL load failed: The specified module could not be found.”

I've spent last 2 days trying to launch examples from Boost.Python with the "ImportError: DLL load failed: The specified module could not be found" error, while trying to load compiled (using bjam) pyd modules. I was using Windows 7 x64, Python 2.7 x64 with Boost 1.47. I've followed up different answers on StackOverflow and other sites incl. fresh installs (Python 32 and 64 bit, Boost precompiled), manual Boost's libraries building, DLL checks with dependency walker and so on, with no luck. I registered to share the solution, which worked here and which I hope may help someone, struggling with the same error ;)

Two solution, no need to use regedit

  1. add BOOST_PYTHON_STATIC_LIB marco when build your dll. It will let boost.python static link to your dll file rather than dynamic load in runtime.
  2. add boost.python dll to PATH or copy it to same dir where your dll locate

The problem was with the KB2264107 Windows update (http://support.microsoft.com/kb/2264107), "messing" with DLL search routine (security fix). Setting the registry value [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager] : CWDIllegalInDllSearch to 0, allowed to properly load DLL files and properly import .pyd modules. This may also happen on other Windows versions.

我的解决方案是下载Microsoft Visual C ++ 2015重新分发 https://www.microsoft.com/zh-cn/download/details.aspx?id=48145

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM