繁体   English   中英

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

[英]Using libspotify .dll/.lib files in MinGW32 compiling pySpotify

在Windows PC上使用MinGW32我正在尝试编译pySpotify 第一个错误是libspotify/api.h丢失了。 我通过将相应的文件夹从libspotify复制到C:\\MinGW\\include 修复此问题。 但是现在dllwrap现在无法使用ld linking. Spotify分发的二进制文件是libspotify.dlllibspotify.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

bok在github上说:

您需要在include路径中添加API头(在编译器选项中添加类似-I~ \\ libspotify \\ include的内容)和库路径中的共享库(将-L~ \\ libspotify \\ lib添加到链接器选项中)。 这将允许编译器找到必要的包含文件,并使链接器找到必要的二进制对象。

然而, distutils Extension类似乎已被弃用且很难找到文档(我相信这是自定义编译器选项需要去的地方)。 感谢~可能需要更改为%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对于参数的顺序是挑剔的。 奇怪的是,当我用Google搜索“ld argument order”时,我得到了一堆页面,暗示订单无关紧要,但我已经被烧了好几次了。 我通过以下参数顺序取得了最大的成功:

  1. 切换到ld (即-Wall
  2. 图书馆搜索路径(即-LPATH
  3. 对象文件
  4. 图书馆(即-lspotify

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

我能想到的最后一件事是,dll扩展可能会让ld感到困惑,您是否尝试将文件名更改为libspotify.so 我知道这是在黑暗中的一种射击,但否则我不知道如何进一步帮助你。

我猜你试图将64位版本的pyspotify与32位版本的libspotify链接起来。 尝试重建pyspotify,将-m32添加到CFLAGS和CXXFLAGS

我已经添加了一些指令,说明如何在问题的实际票证上编译它。 让我知道它是否对你有帮助!

https://github.com/mopidy/pyspotify/issues/63

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM