在MinGW32编译pySpotify中使用libspotify.dll/.lib文件

2024-05-15 22:24:04 发布

您现在位置:Python中文网/ 问答频道 /正文

在Windows PC上使用MinGW32,我正试图编译pySpotify。第一个错误是丢失了libspotify/api.h。通过将适当的文件夹从libspotify复制到C:\MinGW\include,我修复了这个问题。但是现在dllwrap失败了,ld linking.二进制文件{}分布是{}和{},无论我把它们放在哪里(pySpotify文件夹/子文件夹、temp build folders/subfolders和MinGW folders/subfolders)或我给它们命名的名称是什么(.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

bok says on github那:

You need to add the API headers in the include path (add something like -I~\libspotify\include to your compiler options) and the shared library in the library path (add -L~\libspotify\lib to your linker options). This will allow the compiler to find the necessary include files, and your linker to find the necessary binary objects.

然而,distutils扩展类似乎已被弃用,而且很难找到相关文档(我相信这是定制编译器选项需要用到的地方)。请注意,~可能需要更改为%USERPROFILE%或类似名称。类似地,%PYTHONPATH%\Lib\distutils\distutils.cfg除了[build]compiler=mingw32节之外几乎没有文档。这使得编辑compile/link命令及其选项无法更改。在

如何在Windows上编译pySpotify?

编辑:

通过使用python2.6和复制libspotify.dll/libspotify将它们重命名为pythobuild\n26spotify.dll/libspotify.lib I现在从ld收到另一条错误消息:

^{pr2}$

Tags: thetobuildsrcreleaseincludelib错误
3条回答

由于目前无法访问mingw安装,我可以提出一些建议。在

首先,ld对参数的顺序很挑剔。奇怪的是,当我在google上搜索“ld参数顺序”时,我得到了一堆页面,表明顺序无关紧要,但我已经被这个问题烧坏了好几次。我最成功的方法是:

  1. 切换到ld(即,-Wall
  2. 库搜索路径(即-LPATH
  3. 目标文件
  4. 库(即-lspotify

我注意到在你的链接器输出中有一些对amd64的引用。我不确定您是如何编译其他对象文件的,但是由于libspotify在Windows上是32位的,我猜在这里混合使用32/64位不会太好。在

我想不出的最后一件事是,也许dll扩展名与ld混淆了,您是否尝试过将文件名改为libspotify.so?我知道这有点冒险,但不然我不知道该如何帮助你。在

我猜您是在尝试将64位版本的pyspotify与32位版本的libspotify链接起来。尝试重新构建pyspotify,在CFLAGS和cxflags中添加-m32

我已经添加了一些关于如何将它编译到实际发行票上的说明。告诉我这对你有没有帮助!在

{a1}

相关问题 更多 >