[英]Boost Python Magic Number
I am trying to wrap some C++ functions for use in python. 我试图包装一些C ++函数以在python中使用。 For example here is the function from the boost Python tutorial.
例如,这里是boost Python教程中的函数。
// Copyright Joel de Guzman 2002-2004. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
// Hello World Example from the tutorial
// [Joel de Guzman 10/9/2002]
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
char const* greet()
{
return "hello, world";
}
BOOST_PYTHON_MODULE(hello_ext)
{
using namespace boost::python;
def("greet", greet);
}
When I compile this into a .pyc file and try to import it into python I receive the error: 当我将其编译为.pyc文件并尝试将其导入python时,收到错误消息:
ImportError: Bad magic number in C:\\hello_ext.pyc
ImportError:C:\\ hello_ext.pyc中的错误的魔术数字
I have checked the magic number using a method from another forum and it does seem to be wrong. 我已经使用另一个论坛的方法检查了幻数,这似乎是错误的。 I googled around and I haven't been able to find any useful information regarding this error message.
我四处搜寻,但无法找到有关此错误消息的任何有用信息。 I suspect this is a bad setting in my visual studio project file, or maybe something with the way I compiled boost?
我怀疑这在我的Visual Studio项目文件中是一个不良设置,或者与我编译boost的方式有关?
I am using visual studio 2010 service pack 1, python 2.7.3 and boost 1.53 我正在使用Visual Studio 2010 Service Pack 1,Python 2.7.3和Boost 1.53
I compiled boost with the following options. 我用以下选项编译了boost。
b2 install toolset=msvc-10.0 variant=debug,release threading=multi link=shared runtime-link=shared --prefix="C:\boost"
When you compile boost python, you should have got a shared library as a result (eg *.so on my machine), not the .pyc files.. 当您编译boost python时,您应该得到一个共享库(例如,我机器上的* .so),而不是.pyc文件。
This is a page on how to build boost python extension: http://wiki.python.org/moin/boost.python/BuildingExtensions 这是有关如何构建boost python扩展的页面: http : //wiki.python.org/moin/boost.python/BuildingExtensions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.