boost.python“DLL 加载失败”在 WinXP、VisualStudio 2005 上
我在 WinXP-32 上导入 boost-python 模块时遇到问题。 我使用的是 python 2.6.6、boost.python 1.41 由 boostpro 和 VC++8 (VisualStudio 2005) 预编译的库。
编译下面的代码后,我尝试从 python 命令行导入生成的 pyHELLO.pyd 并总是得到:
“导入错误:DLL 加载失败:此 应用程序无法启动 因为应用程序配置 是不正确的。重新安装 应用程序可能会解决此问题。”
我重新安装了python并尝试了其他boost版本。但它们都没有帮助。
我尝试导入模块的目录中有相应的boost dll。
相同的代码适用于VC++9在Win7下,
这是代码:
int sayHello() {
cout << "Hello !" << endl;
}
BOOST_PYTHON_MODULE(pyBoostTest)
{
def("sayHello", sayHello);
}
非常感谢任何帮助。
I have problems importing a boost-python module on WinXP-32.
I'm using python 2.6.6, boost.python 1.41 precompiled libs by boostpro and VC++8 (VisualStudio 2005).
After compiling the piece of code below, I tried to import the resulting pyHELLO.pyd from the python command line and always get:
"ImportError: DLL load failed: This
application has failed to start
because the application configuration
is incorrect. Reinstalling the
application may fix this problem."
I re-installed python and tried other boost versions. But none of it helped.
I have the corresponding boost dlls in the directory where I tried to import the module.
The same code works with VC++9 under Win7.
Here's the code:
int sayHello() {
cout << "Hello !" << endl;
}
BOOST_PYTHON_MODULE(pyBoostTest)
{
def("sayHello", sayHello);
}
Any help highly appreciated.
已解决:
我的计算机上缺少 boost.python dll 所依赖的正确版本的 MSVC80CRT dll。我从MS下载了相应的redist包并安装了。现在可以了。
dependencywalker 没有显示该 dll 缺少的依赖项。
在阅读了清单和 SxS 后,我发现声明了正确的 dll 版本
在清单中,清单本身嵌入在 dll 标头中。
如果您在 Visual Studio 中打开 dll,则可以读取该信息。然后你检查是否
dll 版本存在于 c:\windows\winsxs 文件夹中。如果没有,您可以找回丢失的
dll 通过从 MS 下载相应的“redist”包。直接搜索dll版本即可。
感谢大卫提供有关清单的提示。
Resolved:
The correct version of the MSVC80CRT dll on which the boost.python dll depends was missing on my machine. I downloaded the corresponding redist package from MS and installed it. Now it works.
The dependencywalker did not show a missing dependency for this dll.
After reading about manifests and SxS I found out that the correct dll version is stated
in the manifest which itself is embedded in the dll header.
If you open a dll in Visual Studio you can read the information. Then you check if the
dll version is present in the c:\windows\winsxs folder. If not you can retrieve the missing
dll by downloading a corresponding "redist" package from MS. Just search for the dll version.
Thanks to David for giving the hint on manifests.