2011-01-08 69 views
2

我是否曾試圖使用以下組合: boost_1_45_0,MSVC 10,Python31? (boost_1_45_0 \ libs \ python \ example \ quickstart \ embedding.cpp)既沒有編譯(我發現如何修復它,見下文),也沒有工作。 編譯時間問題:提升Python示例失敗兩次

if (PyImport_AppendInittab("embedded_hello", initembedded_hello) == -1) 
    throw std::runtime_error("Failed to add embedded_hello to the interpreter's " 
      "builtin modules"); 

我發現,正確的名稱是不是initembedded_helloinit_module_embedded_hello。所以我的第一個問題是關於這個重命名的問題嗎?

第二個問題是SystemError: NULL result without error in PyObject_Call導入我的聲明模塊時:

from embedded_hello import * 

註釋掉進口表明,內部Python的模塊(如IO)工作正常。那麼第二個問題是什麼問題導入?

任何幫助,將不勝感激!

+0

一切都建成64位/ 32位? – GWW 2011-01-11 16:24:59

+0

@GWW - 這是32 – Dewfy 2011-01-12 12:30:32

回答

5

使用PyInit_embedded_hello代替Python 3中的initembedded_hello 3.適用於msvc9。

很明顯,quickstart \ embedding.cpp並沒有爲Python 3進行更新。看看pyhon/test/exec.cpp,這是類似和最新的。

Msvc10使用與Python不同的C運行時庫,這可能會導致運行時崩潰。推薦用於構建Python 2.6,2.7,3.1和3.2擴展的編譯器是msvc9,或者是一個與vc90crt鏈接的編譯器。