【发布时间】:2012-12-01 19:04:08
【问题描述】:
在 Windows PC 上使用 MinGW32 我正在尝试编译 pySpotify。第一个错误是缺少libspotify/api.h。我通过将适当的文件夹从libspotify 复制到C:\MinGW\include 来修复这个问题。但是现在dllwrap 现在失败了ld linking. 二进制文件Spotify 分发是libspotify.dll 和libspotify.lib. 无论我把它们放在哪里(pySpotify 文件夹/子文件夹,临时构建文件夹/子文件夹和 MinGW 文件夹/子文件夹) 或我将它们命名为 (.a, .o & .so) 它仍然显示相同的错误消息。
相关错误是:
C:\MinGW\bin\dllwrap.exe -mdll -static --output-lib build\temp.win32-2.7\Release\src\lib_spotify.a --def build\temp.win32-2.7\Release\src\_spotify.def -s build\temp.win32-2.7\Release\src\module.o build\temp.win32-2.7\Release\src\session.o build\temp.win32-2.7\Release\src\link.o build\temp.win32-2.7\Release\src\track.obuild\temp.win32-2.7\Release\src\album.o build\temp.win32-2.7\Release\src\albumbrowser.o build\temp.win32-2.7\Release\src\artist.o build\temp.win32-2.7\Release\src\artistbrowser.o build\temp.win32-2.7\Release\src\search.o build\temp.win32-2.7\Release\src\playlist.o build\temp.win32-2.7\Release\src\playlistcontainer.o build\temp.win32-2.7\Release\src\playlistfolder.o build\temp.win32-2.7\Release\src\image.o build\temp.win32-2.7\Release\src\user.o build\temp.win32-2.7\Release\src\pyspotify.o build\temp.win32-2.7\Release\src\toplistbrowser.o -LC:\Python26\libs -LC:\Python26\PCbuild -lspotify -lpython26 -lmsvcr90 -o build\lib.win32-2.7\spotify\_spotify.pyd
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot find -lspotify
collect2.exe: error: ld returned 1 exit status
dllwrap: gcc exited with status 1
error: command 'dllwrap' failed with exit status 1
您需要在包含路径中添加 API 标头(在编译器选项中添加 -I~\libspotify\include 之类的内容)和库路径中的共享库(在链接器中添加 -L~\libspotify\lib选项)。这将允许编译器找到必要的包含文件,并让您的链接器找到必要的二进制对象。
但是,distutils 扩展类似乎已被弃用,并且很难找到相关文档(我相信这是需要自定义编译器选项的地方)。感谢~ 可能需要更改为%USERPROFILE% 或类似名称。同样,%PYTHONPATH%\Lib\distutils\distutils.cfg 除了[build] compiler=mingw32 节之外几乎没有文档。这使得编辑编译/链接命令及其选项无法更改。
如何在 Windows 上编译 pySpotify?
编辑:
通过使用 Python 2.6 并将 libspotify.dll/libspotify.lib 复制到 C:\Python26\PCbuild 并将它们重命名为 spotify.dll/libspotify.lib 我现在收到来自 ld 的另一条错误消息:
C:\MinGW\bin\dllwrap.exe -mdll -static --output-lib build\temp.win32-2.6\Release\src\lib_spotify.a --def build\temp.win32-2.6\Release\src\_spotify.def -s build\temp.win32-2.6\Release\src\module.o build\temp.win32-2.6\Release\src\session.o build\temp.win32-2.6\Release\src\link.o build\temp.win32-2.6\Release\src\track.obuild\temp.win32-2.6\Release\src\album.o build\temp.win32-2.6\Release\src\albumbrowser.o build\temp.win32-2.6\Release\src\artist.o build\temp.win32-2.6\Release\src\artistbrowser.o build\temp.win32-2.6\Release\src\search.o build\temp.win32-2.6\Release\src\playlist.o build\temp.win32-2.6\Release\src\playlistcontainer.o build\temp.win32-2.6\Release\src\playlistfolder.o build\temp.win32-2.6\Release\src\image.o build\temp.win32-2.6\Release\src\user.o build\temp.win32-2.6\Release\src\pyspotify.o build\temp.win32-2.6\Release\src\toplistbrowser.o -LC:\Python26\libs -LC:\Python26\PCbuild -lspotify -lpython26 -lmsvcr90 -o build\lib.win32-2.6\spotify\_spotify.pyd
_spotify.exp: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
dllwrap: gcc exited with status 1
error: command 'dllwrap' failed with exit status 1
【问题讨论】:
-
也许 mingw 的 ld 没有正确读取绝对路径?也就是说,尝试将 libspotify 移动到相对位置,看看是否没有帮助。
-
嗨 Nik,感谢您的建议 - 但我尝试复制到我能找到的每个文件夹/子文件夹无济于事:“无论我把它们放在哪里(pySpotify 文件夹/子文件夹,临时构建文件夹/subfolders 和 MinGW 文件夹/子文件夹)。”