2009-06-18 88 views
2

當結合使用的virtualenv在Windows上使用MinGW的編譯器,編譯以下錯誤C擴展的結果:如何在virtualenv中使用MinGW編譯Python C擴展?

 
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lpython25 
collect2: ld returned 1 exit status 
error: Setup script exited with error: command 'gcc' failed with exit status 1 

應該怎樣做一個成功編譯C擴展?

回答

6

設置LIBRARY_PATH環境變量,以便MinGW知道在哪裏可以找到系統範圍的Python libpython25.a

放置在一個行你的virtualenv的activate.bat

set LIBRARY_PATH=c:\python25\libs 

或者在Windows中設置一個全球性的環境變量。

如果您不使用版本2.5,請確保將25更改爲與您的Python版本相對應。

+0

非常感謝您用答案更新您的問題。正在與同樣的問題掙扎,這是問題! – aravenel 2012-08-23 15:44:18