2013-03-05 83 views
1

我想包装一些用于python的C++函数。例如,这里是boost Python教程中的函数。Boost Python Magic Number

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

当我编译这个成.pyc文件文件,并尝试将其导入到蟒蛇我收到的错误:

ImportError: Bad magic number in C:\hello_ext.pyc

我一直在使用的方法从另一个论坛检查幻数和它似乎是错的。我搜索了一下,我一直无法找到任何有关此错误消息的有用信息。我怀疑这是一个糟糕的设置在我的Visual Studio项目文件,或者可能是我编译boost的方式?

我使用Visual Studio 2010 Service Pack 1中,蟒蛇2.7.3和加强与下列选项1.53

我编的推动作用。

b2 install toolset=msvc-10.0 variant=debug,release threading=multi link=shared runtime-link=shared --prefix="C:\boost" 
+0

谢谢,解决了这个问题。我现在感觉只是一个小傻瓜:) – user2137072 2013-03-05 20:27:59

+0

如果你想添加这个作为答案,我会标记它是正确的。 – user2137072 2013-03-05 20:42:51

回答