在Windows(VC90)中使用C绑定构建Python包会导致LNK1181致命错误



我正在尝试构建一个绑定到C库(libspotify)的Python包(pyspotify。

我使用的是Python2.7.5,并安装了VS2008Express以获得一些必需的命令行工具。

当我从命令提示符(具有管理员权限)调用python setup.py build时,我得到以下输出:

running build
running build_py
running build_ext
building 'spotify._spotify' extension

然后大约18个,包中每个.c文件一个:

c:Program Files (x86)Microsoft Visual Studio 9.0VCBINcl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -Isrc -Ic:PythonPython27include -Ic:PythonPython27PC
/Tcsrcmodule.c /Fobuildtemp.win32-2.7Releasesrcmodule.obj
module.c

然后是引人注目的:

c:Program Files (x86)Microsoft Visual Studio 9.0VCBINlink.exe /DLL /nologo
/INCREMENTAL:NO /LIBPATH:c:PythonPython27libs /LIBPATH:c:PythonPython27PCb
uild spotify.lib /EXPORT:init_spotify buildtemp.win32-2.7Releasesrcmodule.ob
j buildtemp.win32-2.7Releasesrcsession.obj buildtemp.win32-2.7Releasesrc
link.obj buildtemp.win32-2.7Releasesrctrack.obj buildtemp.win32-2.7Release
srcalbum.obj buildtemp.win32-2.7Releasesrcalbumbrowser.obj buildtemp.win3
2-2.7Releasesrcartist.obj buildtemp.win32-2.7Releasesrcartistbrowser.obj
buildtemp.win32-2.7Releasesrcsearch.obj buildtemp.win32-2.7Releasesrcpla
ylist.obj buildtemp.win32-2.7Releasesrcplaylistcontainer.obj buildtemp.win3
2-2.7Releasesrcplaylistfolder.obj buildtemp.win32-2.7Releasesrcimage.obj
buildtemp.win32-2.7Releasesrcuser.obj buildtemp.win32-2.7Releasesrcpyspo
tify.obj buildtemp.win32-2.7Releasesrctoplistbrowser.obj /OUT:buildlib.win3
2-2.7spotify_spotify.pyd /IMPLIB:buildtemp.win32-2.7Releasesrc_spotify.lib
 /MANIFESTFILE:buildtemp.win32-2.7Releasesrc_spotify.pyd.manifest
LINK : fatal error LNK1181: cannot open input file 'spotify.lib'
error: command '"c:Program Files (x86)Microsoft Visual Studio 9.0VCBINlink.
exe"' failed with exit status 1181

我试着搜索这个LNK1181错误,但所有的答案似乎都是关于记住字符串周围的引号,或者VS中的一些设置,在这种情况下我无法控制。

您需要从这里下载合适版本的libspotify,将其解压缩并放在您尝试构建的同一目录中(最简单的地方),或者告诉VS在哪里可以找到它。

最新更新