2013-03-05 60 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

回答