首页 文章

如何在virtualenv中使用MinGW编译Python C扩展?

提问于
浏览
2

在Windows上使用virtualenv与MinGW编译器结合使用时,编译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扩展?

1 回答

  • 6

    设置 LIBRARY_PATH 环境变量,以便MinGW知道在哪里可以找到系统范围的Python libpython25.a .

    在你的virtualenv的_2956539中放一条线:

    set LIBRARY_PATH=c:\python25\libs
    

    或者在Windows中设置全局环境变量 .

    如果您没有使用2.5版,请务必更改 25 以对应您的Python版本 .

相关问题