Boost.Python examples, Windows 7 x64, "ImportError: DLL load failed: The specified module could not be found."
Asked Answered
C

3

5

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 ;)

Cham answered 13/11, 2011 at 12:56 Comment(4)
The problem was with the KB2264107 Windows update, "fixing" the 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.Cham
welcome to SO. Note that SO is an answer and questions site. It is not a blog to log your accomplishements in programming.Grisons
@Grisons I know, but how can I share the solution when someone will struggle with the similar problem? If it's a very discouraged manner and this thread is not proper, please moderator remove it.Cham
your answer below is perfectly valid but you should not include your answer in the place for comments as above or in the question itself. Keep it as a question as concise and precise as possible.Grisons
C
2

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.

Cham answered 13/11, 2011 at 22:59 Comment(0)
T
6

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
Titular answered 2/3, 2016 at 1:53 Comment(1)
I got the same problem. It is related to DLL search path but has nothing to do with the KB2264107 Windows update ("fixing" of the DLL search routine). 2 is the correct answer.Emie
C
2

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.

Cham answered 13/11, 2011 at 22:59 Comment(0)
I
0

my soluition is download microsoft visual c++ 2015 redistribute https://www.microsoft.com/en-us/download/details.aspx?id=48145

Illiberal answered 27/7, 2017 at 2:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.